Skip to content

Commit 4c24b34

Browse files
authored
Merge pull request #94 from OS2borgerPC/93-update-pipeline-with-iso-download-information
issue #93 - update release notes instead of replacement
2 parents 61989a3 + ca9631c commit 4c24b34

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

.github/workflows/build_iso.yml

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ on:
1111

1212
jobs:
1313
build-and-release-iso:
14-
runs-on: ubuntu-latest
14+
runs-on: ubuntu-22.04
15+
16+
env:
17+
UBUNTU_ISO_URL: https://releases.ubuntu.com/22.04/ubuntu-22.04.5-desktop-amd64.iso
18+
UBUNTU_ISO_FILENAME: ubuntu-22.04.5-desktop-amd64.iso
1519

1620
steps:
1721
- name: Checkout repository
@@ -21,15 +25,15 @@ jobs:
2125
id: cache-ubuntu-iso
2226
uses: actions/cache@v3
2327
with:
24-
path: ubuntu-22.04.5-desktop-amd64.iso
25-
key: ubuntu-iso-${{ runner.os }}-${{ hashFiles('ubuntu-22.04.5-desktop-amd64.iso') }}
28+
path: ${{ env.UBUNTU_ISO_FILENAME }}
29+
key: ubuntu-iso-${{ runner.os }}-${{ hashFiles(env.UBUNTU_ISO_FILENAME) }}
2630
restore-keys: |
2731
ubuntu-iso-${{ runner.os }}-
2832
2933
- name: Download Ubuntu ISO if not cached
3034
if: steps.cache-ubuntu-iso.outputs.cache-hit != 'true'
3135
run: |
32-
wget -O ubuntu-22.04.5-desktop-amd64.iso https://releases.ubuntu.com/22.04/ubuntu-22.04.5-desktop-amd64.iso
36+
wget -O ${{ env.UBUNTU_ISO_FILENAME }} ${{ env.UBUNTU_ISO_URL }}
3337
3438
- name: Determine ISO filename
3539
id: get-filename
@@ -42,7 +46,7 @@ jobs:
4246
4347
- name: Build OS2borgerpc image
4448
run: |
45-
cd image && ./build_os2borgerpc_image.sh ../ubuntu-22.04.5-desktop-amd64.iso $FILENAME
49+
cd image && ./build_os2borgerpc_image.sh ../${{ env.UBUNTU_ISO_FILENAME }} $FILENAME
4650
4751
- name: Upload ISO as an artifact (for non-release events)
4852
if: github.event_name != 'release'
@@ -58,12 +62,23 @@ jobs:
5862
env:
5963
AWS_ACCESS_KEY_ID: ${{ secrets.HETZNER_OS2BORGERPC_ACCESS_KEY }}
6064
AWS_SECRET_ACCESS_KEY: ${{ secrets.HETZNER_OS2BORGERPC_SECRET_KEY }}
61-
- name: Add download URL to release notes
65+
66+
- name: Append download URL to release notes
6267
if: github.event_name == 'release'
6368
run: |
69+
# Fetch the current release notes
70+
CURRENT_BODY=$(curl -s \
71+
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
72+
https://api.github.com/repos/${{ github.repository }}/releases/${{ github.event.release.id }} \
73+
| jq -r .body)
74+
75+
# Update the release notes with new content appended, jq used to escape the JSON properly.
6476
DOWNLOAD_URL="https://fsn1.your-objectstorage.com/os2borgerpc/borgerpc-os-images/${{ env.FILENAME }}.iso"
77+
UPDATED_BODY=$(printf "%s\r\n## Download the ISO\r\n%s" "$CURRENT_BODY" "$DOWNLOAD_URL" | jq -Rs .)
78+
79+
# Patch the release notes
6580
curl -X PATCH \
6681
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
6782
-H "Content-Type: application/json" \
68-
-d "{\"body\": \"Download the ISO here: $DOWNLOAD_URL\"}" \
83+
-d "{\"body\": $UPDATED_BODY}" \
6984
https://api.github.com/repos/${{ github.repository }}/releases/${{ github.event.release.id }}

0 commit comments

Comments
 (0)