Skip to content

Commit ada516d

Browse files
committed
fix: build tag rate limit issues
building image jobs are sometimes failing to fetch repo latest tags. printing debug showed it was getting rate limited. GH rate limits by IP for unauthenticated requests. Fix by using GH token. Signed-off-by: Amanda Liem <[email protected]>
1 parent 36bc8ff commit ada516d

File tree

4 files changed

+22
-10
lines changed

4 files changed

+22
-10
lines changed

.github/workflows/build-and-release.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,22 @@ jobs:
8888
sudo apt update
8989
sudo apt install -y mkosi
9090
91+
- name: Fetch latest release tags
92+
env:
93+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
94+
run: |
95+
set -euo pipefail
96+
97+
# Fetch latest tags using gh CLI (automatically authenticated)
98+
SNPGUEST_TAG=$(gh release view --repo virtee/snpguest --json tagName --jq '.tagName')
99+
BEACON_TAG=$(gh release view --repo AMDEPYC/beacon --json tagName --jq '.tagName')
100+
SNPHOST_TAG=$(gh release view --repo virtee/snphost --json tagName --jq '.tagName')
101+
102+
# Inject environment variables into mkosi.conf files
103+
sed -i "/^\[Build\]/a\Environment=SNPGUEST_TAG=$SNPGUEST_TAG" modules/snpguest-build/mkosi.conf
104+
sed -i "/^\[Build\]/a\Environment=BEACON_TAG=$BEACON_TAG" modules/beacon/mkosi.conf
105+
sed -i "/^\[Build\]/a\Environment=SNPHOST_TAG=$SNPHOST_TAG" modules/snphost/mkosi.conf
106+
91107
- name: Build guest-${{ matrix.distro }}-${{ matrix.release }}
92108
run: |
93109
sudo mkosi --image-id=guest-${{ matrix.distro }}-${{ matrix.release }} -C images/guest-${{ matrix.distro }}-${{ matrix.release }}/ cat-config
@@ -156,4 +172,3 @@ jobs:
156172
"https://uploads.github.com/repos/$GITHUB_REPOSITORY/releases/$RELEASE_ID/assets?name=$ASSET_NAME"
157173
env:
158174
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
159-

modules/beacon/mkosi.build

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
set -euo pipefail
33
set -x
44

5-
# Fetch latest release tag from GitHub API using jq
6-
LATEST_TAG=$(curl -s https://api.github.com/repos/AMDEPYC/beacon/releases/latest \
7-
| jq -r '.tag_name')
5+
# Use BEACON_TAG if set, otherwise fetch from GitHub API
6+
LATEST_TAG="${BEACON_TAG:-$(curl -s https://api.github.com/repos/AMDEPYC/beacon/releases/latest | jq -r '.tag_name')}"
87

98
# Download and install into DESTDIR with correct permissions
109
curl -fsSL "https://github.com/AMDEPYC/beacon/releases/download/${LATEST_TAG}/beacon-linux-x86_64" \

modules/snpguest-build/mkosi.build

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
set -euo pipefail
33
set -x
44

5-
# Fetch latest release tag from GitHub API
6-
LATEST_TAG=$(curl -s https://api.github.com/repos/virtee/snpguest/releases/latest \
7-
| jq -r '.tag_name')
5+
# Use SNPGUEST_TAG if set, otherwise fetch from GitHub API
6+
LATEST_TAG="${SNPGUEST_TAG:-$(curl -s https://api.github.com/repos/virtee/snpguest/releases/latest | jq -r '.tag_name')}"
87

98
# Download and install into DESTDIR with correct permissions
109
curl -fsSL "https://github.com/virtee/snpguest/releases/download/${LATEST_TAG}/snpguest" \

modules/snphost/mkosi.build

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
set -euo pipefail
33
set -x
44

5-
# Fetch latest release tag from GitHub API
6-
LATEST_TAG=$(curl -s https://api.github.com/repos/virtee/snphost/releases/latest \
7-
| jq -r '.tag_name')
5+
# Use SNPHOST_TAG if set, otherwise fetch from GitHub API
6+
LATEST_TAG="${SNPHOST_TAG:-$(curl -s https://api.github.com/repos/virtee/snphost/releases/latest | jq -r '.tag_name')}"
87

98
# Download and install into DESTDIR with correct permissions
109
curl -fsSL "https://github.com/virtee/snphost/releases/download/${LATEST_TAG}/snphost" \

0 commit comments

Comments
 (0)