-
Notifications
You must be signed in to change notification settings - Fork 4
85 lines (72 loc) · 3.21 KB
/
build_iso.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
76
77
78
79
80
81
82
83
84
85
name: Build and Release Custom Ubuntu ISO
on:
push:
branches:
- main
- master
release:
types: [created]
workflow_dispatch:
jobs:
build-and-release-iso:
runs-on: ubuntu-22.04
env:
UBUNTU_ISO_URL: https://releases.ubuntu.com/22.04/ubuntu-22.04.5-desktop-amd64.iso
UBUNTU_ISO_FILENAME: ubuntu-22.04.5-desktop-amd64.iso
DELETE_DOWNLOADED_ISO: true # Used by build_os2borgerpc_image.sh
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up cache for Ubuntu ISO
id: cache-ubuntu-iso
uses: actions/cache@v3
with:
path: ${{ env.UBUNTU_ISO_FILENAME }}
key: ubuntu-iso-${{ runner.os }}-${{ hashFiles(env.UBUNTU_ISO_FILENAME) }}
restore-keys: |
ubuntu-iso-${{ runner.os }}-
- name: Download Ubuntu ISO if not cached
if: steps.cache-ubuntu-iso.outputs.cache-hit != 'true'
run: |
wget -O ${{ env.UBUNTU_ISO_FILENAME }} ${{ env.UBUNTU_ISO_URL }}
- name: Determine ISO filename
id: get-filename
run: |
if [[ "${{ github.event_name }}" == "release" ]]; then
echo "FILENAME=borgerpc-amd64-${{ github.event.release.tag_name }}" >> $GITHUB_ENV
else
echo "FILENAME=borgerpc-amd64-dev" >> $GITHUB_ENV
fi
- name: Build OS2borgerpc image
run: |
cd image && ./build_os2borgerpc_image.sh ../${{ env.UBUNTU_ISO_FILENAME }} $FILENAME
- name: Upload ISO as an artifact (for non-release events)
if: github.event_name != 'release'
uses: actions/upload-artifact@v4
with:
name: ${{ env.FILENAME }}.iso
path: ./image/${{ env.FILENAME }}.iso
- name: Release ISO for public access (only for release events)
if: github.event_name == 'release'
run: |
aws s3 --endpoint-url https://fsn1.your-objectstorage.com cp ./image/${{ env.FILENAME }}.iso s3://os2borgerpc/borgerpc-os-images/${{ env.FILENAME }}.iso
env:
AWS_ACCESS_KEY_ID: ${{ secrets.HETZNER_OS2BORGERPC_ACCESS_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.HETZNER_OS2BORGERPC_SECRET_KEY }}
- name: Append download URL to release notes
if: github.event_name == 'release'
run: |
# Fetch the current release notes
CURRENT_BODY=$(curl -s \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/repos/${{ github.repository }}/releases/${{ github.event.release.id }} \
| jq -r .body)
# Update the release notes with new content appended, jq used to escape the JSON properly.
DOWNLOAD_URL="https://fsn1.your-objectstorage.com/os2borgerpc/borgerpc-os-images/${{ env.FILENAME }}.iso"
UPDATED_BODY=$(printf "%s\r\n## Download the ISO\r\n%s" "$CURRENT_BODY" "$DOWNLOAD_URL" | jq -Rs .)
# Patch the release notes
curl -X PATCH \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: application/json" \
-d "{\"body\": $UPDATED_BODY}" \
https://api.github.com/repos/${{ github.repository }}/releases/${{ github.event.release.id }}