Skip to content

Commit f34b15b

Browse files
authored
Merge pull request #710 from dappnode/auto/update-base-isos-workflow-v2
Improve ISO update workflow: close stale PRs and use GitHub App token
2 parents 20d53c2 + faa8a8f commit f34b15b

1 file changed

Lines changed: 34 additions & 4 deletions

File tree

.github/workflows/update-base-isos.yml

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,17 @@ on:
66
- cron: "0 8 * * *"
77
workflow_dispatch:
88

9-
permissions:
10-
contents: write
11-
pull-requests: write
12-
139
jobs:
1410
update-ubuntu-iso:
1511
name: Check for Ubuntu ISO updates
1612
runs-on: ubuntu-latest
1713
steps:
14+
- uses: actions/create-github-app-token@v1
15+
id: app-token
16+
with:
17+
app-id: ${{ vars.TROPI_APP_ID }}
18+
private-key: ${{ secrets.TROPI_APP_PRIVATE_KEY }}
19+
1820
- name: Checkout Code
1921
uses: actions/checkout@v6
2022

@@ -59,10 +61,21 @@ jobs:
5961
echo "current_iso=$CURRENT_ISO" >> "$GITHUB_OUTPUT"
6062
echo "latest_iso=$LATEST_ISO" >> "$GITHUB_OUTPUT"
6163
64+
- name: Close outdated Ubuntu ISO PR
65+
if: steps.ubuntu.outputs.updated == 'true'
66+
env:
67+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
68+
run: |
69+
EXISTING_PR=$(gh pr list --head auto/update-ubuntu-iso --state open --json number --jq '.[0].number')
70+
if [ -n "$EXISTING_PR" ]; then
71+
gh pr close "$EXISTING_PR" --comment "Superseded by a newer Ubuntu ISO version (${{ steps.ubuntu.outputs.latest_iso }})." --delete-branch
72+
fi
73+
6274
- name: Create Pull Request for Ubuntu ISO update
6375
if: steps.ubuntu.outputs.updated == 'true'
6476
uses: peter-evans/create-pull-request@v7
6577
with:
78+
token: ${{ steps.app-token.outputs.token }}
6679
commit-message: "Update Ubuntu base ISO to ${{ steps.ubuntu.outputs.latest_iso }}"
6780
branch: auto/update-ubuntu-iso
6881
delete-branch: true
@@ -80,6 +93,12 @@ jobs:
8093
name: Check for Debian ISO updates
8194
runs-on: ubuntu-latest
8295
steps:
96+
- uses: actions/create-github-app-token@v1
97+
id: app-token
98+
with:
99+
app-id: ${{ vars.TROPI_APP_ID }}
100+
private-key: ${{ secrets.TROPI_APP_PRIVATE_KEY }}
101+
83102
- name: Checkout Code
84103
uses: actions/checkout@v6
85104

@@ -139,10 +158,21 @@ jobs:
139158
echo "current_iso=$CURRENT_ISO" >> "$GITHUB_OUTPUT"
140159
echo "latest_iso=$LATEST_ISO" >> "$GITHUB_OUTPUT"
141160
161+
- name: Close outdated Debian ISO PR
162+
if: steps.debian.outputs.updated == 'true'
163+
env:
164+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
165+
run: |
166+
EXISTING_PR=$(gh pr list --head auto/update-debian-iso --state open --json number --jq '.[0].number')
167+
if [ -n "$EXISTING_PR" ]; then
168+
gh pr close "$EXISTING_PR" --comment "Superseded by a newer Debian ISO version (${{ steps.debian.outputs.latest_iso }})." --delete-branch
169+
fi
170+
142171
- name: Create Pull Request for Debian ISO update
143172
if: steps.debian.outputs.updated == 'true'
144173
uses: peter-evans/create-pull-request@v7
145174
with:
175+
token: ${{ steps.app-token.outputs.token }}
146176
commit-message: "Update Debian base ISO to ${{ steps.debian.outputs.latest_iso }}"
147177
branch: auto/update-debian-iso
148178
delete-branch: true

0 commit comments

Comments
 (0)