Skip to content

Commit 4706801

Browse files
author
Lessley Dennington
authored
Merge pull request #377 from ldennington/update-linux-deployments
Update apt-get workflow to publish to official bionic/hirsute repos
2 parents 5ed190b + 036e757 commit 4706801

File tree

3 files changed

+58
-99
lines changed

3 files changed

+58
-99
lines changed

.github/configure_repoclient.py

Lines changed: 0 additions & 35 deletions
This file was deleted.

.github/fetch_release.py

Lines changed: 0 additions & 49 deletions
This file was deleted.

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

Lines changed: 58 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,39 +14,82 @@ jobs:
1414
release:
1515
runs-on: ubuntu-latest
1616
steps:
17-
- name: setup python
18-
uses: actions/setup-python@v2
19-
with:
20-
python-version: 3.8
21-
2217
- uses: actions/checkout@v2
2318

2419
- uses: azure/login@v1
2520
with:
2621
creds: ${{ secrets.AZURE_CREDENTIALS }}
2722

28-
- name: 'Download Repo Client'
23+
- name: "Download Repo Client"
2924
env:
3025
AZ_SUB: ${{ secrets.AZURE_SUBSCRIPTION }}
3126
run: |
3227
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
3328
3429
- name: "Install Repo Client"
35-
env:
36-
APT_REPO_ID: ${{ secrets.APT_REPO_ID }}
37-
AZURE_AAD_ID: ${{ secrets.AZURE_AAD_ID }}
38-
AAD_CLIENT_SECRET: ${{ secrets.AAD_CLIENT_SECRET }}
3930
run: |
4031
sudo apt-get install python3-adal --yes
4132
sudo dpkg -i repoclient.deb
42-
python .github/configure_repoclient.py
4333
rm repoclient.deb
4434
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+
4588
- name: "Publish to apt feed"
4689
env:
4790
RELEASE: ${{ github.event.inputs.release }}
4891
run: |
49-
pip install requests
50-
python .github/fetch_release.py
51-
wget "$(cat asset_url.txt)"
52-
repoclient -v v3 -c config.json package add --check --wait 300 "$(cat asset_name.txt)"
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)