forked from Ed-Fi-Alliance-OSS/AdminAPI-2.x
-
Notifications
You must be signed in to change notification settings - Fork 0
75 lines (62 loc) · 2.5 KB
/
on-release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# SPDX-License-Identifier: Apache-2.0
# Licensed to the Ed-Fi Alliance under one or more agreements.
# The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0.
# See the LICENSE and NOTICES files in the project root for more information.
name: On Release
on:
release:
types:
- released
env:
ARTIFACTS_API_KEY: ${{ secrets.AZURE_ARTIFACTS_PERSONAL_ACCESS_TOKEN }}
ARTIFACTS_FEED_URL: ${{ secrets.AZURE_ARTIFACTS_FEED_URL }}
ARTIFACTS_PACKAGES_URL: ${{ secrets.ARTIFACTS_PACKAGES_URL }}
ARTIFACTS_USERNAME: ${{ secrets.AZURE_ARTIFACTS_USER_NAME }}
jobs:
delete-pre-releases:
name: Delete Unnecessary Pre-Releases
runs-on: ubuntu-latest
steps:
- name: Checkout the repo
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: Delete other pre-releases and their tags
shell: pwsh
run: |
$release = "${{ github.ref_name }}"
$repo = "${{ github.repository }}"
$token = "${{ secrets.GITHUB_TOKEN }}"
$page = 1
$release_list = @()
Do {
$url = "https://api.github.com/repos/$repo/releases?per_page=100&page=$page"
$gh_headers = @{
"Accept" = "application/vnd.github+json"
"Authorization" = "Bearer $token"
}
$release_list = Invoke-RestMethod $url -Headers $gh_headers
$release_list | ForEach-Object {
if ($_.tag_name -like "Pre-Release-*" -and $_.prerelease) {
"Deleting pre-release $($_.tag_name)" | Write-Output
Invoke-RestMethod -Method Delete -Uri $_.url -Headers $gh_headers
}
}
$page += 1
} While ($release_list.count -gt 0)
promote-Azure-artifact:
name: Promote Azure Artifact
runs-on: ubuntu-latest
steps:
- name: Checkout the repo
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: Promote Package
shell: pwsh
run: |
$arguments = @{
FeedsURL = "${{ env.ARTIFACTS_FEED_URL }}"
PackagesURL = "${{ env.ARTIFACTS_PACKAGES_URL }}"
Username = "${{ env.ARTIFACTS_USERNAME }}"
View = "release"
ReleaseRef = "${{ github.ref_name }}"
Password = (ConvertTo-SecureString -String "${{ env.ARTIFACTS_API_KEY }}" -AsPlainText -Force)
}
./eng/promote-packages.ps1 @arguments