Skip to content

Commit 9f32d72

Browse files
committed
Create a PR for update-ubuntu-digest workflow
The current workflow doesn't work because it tries to commit and push to main. This changes it to create a PR with the changes instead. We're using an app token for the PR, so the GITHUB_TOKEN permissions can be downgraded to just contents:read
1 parent f426265 commit 9f32d72

1 file changed

Lines changed: 23 additions & 13 deletions

File tree

.github/workflows/update-ubuntu-digest.yaml

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,34 @@ env:
1111
BASE_IMAGE_NAME: base-docker
1212
ACTION_IMAGE_NAME: base-action
1313
permissions:
14-
contents: write
14+
contents: read
1515
jobs:
1616
update:
1717
runs-on: ubuntu-latest
1818
steps:
1919
- name: Checkout
20-
uses: actions/checkout@master
20+
uses: actions/checkout@v6
2121
- uses: extractions/setup-just@69d82fb0233557aec017ef13706851d0694e0f1d
2222
- name: update image digests
2323
run: just update-docker-image-digests
24-
- name: Commit file
25-
run: |
26-
git status
27-
git add "*.digest"
28-
if git diff-index --quiet HEAD; then
29-
exit
30-
fi
31-
git config --local user.email "action@github.com"
32-
git config --local user.name "GitHub Action"
33-
git commit -m "Update base image digest files"
34-
git push origin
24+
25+
- uses: actions/create-github-app-token@v2
26+
id: generate-token
27+
with:
28+
app-id: ${{ vars.CREATE_PR_APP_ID }}
29+
private-key: ${{ secrets.CREATE_PR_APP_PRIVATE_KEY }}
30+
31+
- name: Create a Pull Request if there are any changes
32+
id: create_pr
33+
uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0 # v8.1.0
34+
with:
35+
branch: bot/update-ubuntu-digest
36+
add-paths: "*.digest"
37+
base: main
38+
author: "opensafely-github-bot <opensafely-github-bot@users.noreply.github.com>"
39+
committer: "opensafely-github-bot <opensafely-github-bot@users.noreply.github.com>"
40+
commit-message: "Update base image digest files"
41+
title: "Update base image digest files"
42+
body: Automated changes by [update-dependencies-action](https://github.com/bennettoxford/update-dependencies-action)
43+
token: ${{ steps.generate-token.outputs.token }}
44+
sign-commits: true

0 commit comments

Comments
 (0)