Skip to content

Commit 9411662

Browse files
Lessley Denningtonderrickstolee
authored andcommitted
Merge pull request git-for-windows#386 from ldennington/add-release-apt-get-workflow
Add release-apt-get workflow
2 parents 71e7e93 + 9eebae7 commit 9411662

File tree

1 file changed

+95
-0
lines changed

1 file changed

+95
-0
lines changed

.github/workflows/release-apt-get.yml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: "release-apt-get"
2+
on:
3+
release:
4+
types: [released]
5+
6+
workflow_dispatch:
7+
inputs:
8+
release:
9+
description: 'Release Tag'
10+
required: true
11+
default: 'latest'
12+
13+
jobs:
14+
release:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v2
18+
19+
- uses: azure/login@v1
20+
with:
21+
creds: ${{ secrets.AZURE_CREDENTIALS }}
22+
23+
- name: "Download Repo Client"
24+
env:
25+
AZ_SUB: ${{ secrets.AZURE_SUBSCRIPTION }}
26+
run: |
27+
az storage blob download --subscription "$AZ_SUB" --account-name gitcitoolstore -c tools -n azure-repoapi-client_2.0.1_amd64.deb -f repoclient.deb --auth-mode login
28+
29+
- name: "Install Repo Client"
30+
run: |
31+
sudo apt-get install python3-adal --yes
32+
sudo dpkg -i repoclient.deb
33+
rm repoclient.deb
34+
35+
- name: "Configure Repo Client"
36+
uses: actions/github-script@v3
37+
env:
38+
AZURE_AAD_ID: ${{ secrets.AZURE_AAD_ID }}
39+
AAD_CLIENT_SECRET: ${{ secrets.AAD_CLIENT_SECRET }}
40+
with:
41+
script: |
42+
for (const key of ['AZURE_AAD_ID', 'AAD_CLIENT_SECRET']) {
43+
if (!process.env[key]) throw new Error(`Required env var ${key} is missing!`)
44+
}
45+
const config = {
46+
AADResource: 'https://microsoft.onmicrosoft.com/945999e9-da09-4b5b-878f-b66c414602c0',
47+
AADTenant: '72f988bf-86f1-41af-91ab-2d7cd011db47',
48+
AADAuthorityUrl: 'https://login.microsoftonline.com',
49+
server: 'azure-apt-cat.cloudapp.net',
50+
port: '443',
51+
AADClientId: process.env.AZURE_AAD_ID,
52+
AADClientSecret: process.env.AAD_CLIENT_SECRET,
53+
repositoryId: ''
54+
}
55+
const fs = require('fs')
56+
fs.writeFileSync('config.json', JSON.stringify(config, null, 2))
57+
58+
- name: "Get Release Asset"
59+
id: get-asset
60+
env:
61+
RELEASE: ${{ github.event.inputs.release }}
62+
uses: actions/github-script@v3
63+
with:
64+
github-token: ${{secrets.GITHUB_TOKEN}}
65+
script: |
66+
const { data } = await github.repos.getRelease({
67+
owner: context.repo.owner,
68+
repo: context.repo.repo,
69+
release_id: process.env.RELEASE || 'latest'
70+
})
71+
const assets = data.assets.filter(asset => asset.name.endsWith('.deb'))
72+
if (assets.length !== 1) {
73+
throw new Error(`Unexpected number of .deb assets: ${assets.length}`)
74+
}
75+
const fs = require('fs')
76+
const buffer = await github.repos.getReleaseAsset({
77+
headers: {
78+
accept: 'application/octet-stream'
79+
},
80+
owner: context.repo.owner,
81+
repo: context.repo.repo,
82+
asset_id: assets[0].id
83+
})
84+
console.log(buffer)
85+
fs.writeFileSync(assets[0].name, Buffer.from(buffer.data))
86+
core.setOutput('name', assets[0].name)
87+
88+
- name: "Publish to apt feed"
89+
env:
90+
RELEASE: ${{ github.event.inputs.release }}
91+
run: |
92+
for id in ${{ secrets.BIONIC_REPO_ID }} ${{ secrets.HIRSUTE_REPO_ID }}
93+
do
94+
repoclient -v v3 -c config.json package add --check --wait 300 "${{steps.get-asset.outputs.name}}" -r $id
95+
done

0 commit comments

Comments
 (0)