11# CI job to periodically (once a week) update flake.lock
22name : Update flake dependencies
3-
43on :
54 schedule :
65 - cron : ' 0 16 * * 5'
76 workflow_dispatch : # for allowing manual triggers of the workflow
8-
97jobs :
108 update-dependencies :
119 runs-on : ubuntu-latest
1210 steps :
13- - uses : actions/checkout@v4
14- - uses : DeterminateSystems/nix-installer-action@main
15- - uses : DeterminateSystems/magic-nix-cache-action@main
16- - name : Update flake.lock and create signed commit with flake.lock changes
17- env :
18- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
19- FILE_TO_COMMIT : flake.lock
20- COMMIT_BRANCH : automation/update-flake-dependencies
21- COMMIT_MESSAGE : " chore(nix): Update Flake dependencies"
22- run : |
11+ - uses : actions/checkout@v4
12+ - uses : DeterminateSystems/nix-installer-action@main
13+ - uses : DeterminateSystems/magic-nix-cache-action@main
14+ - name : Update flake.lock and create signed commit with flake.lock changes
15+ env :
16+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
17+ FILE_TO_COMMIT : flake.lock
18+ COMMIT_BRANCH : automation/update-flake-dependencies
19+ COMMIT_MESSAGE : " chore(nix): Update Flake dependencies"
20+ run : |
2321 # fetch remote state
2422 git fetch
2523 # if branch exists on remote already
24+ BRANCH_EXISTS=false
2625 if git checkout "$COMMIT_BRANCH" > /dev/null 2>&1; then
2726 # pull changes
2827 git pull
28+ BRANCH_EXISTS=true
2929 else
3030 # otherwise, create the branch and push it to remote
3131 git checkout -b "$COMMIT_BRANCH"
@@ -41,10 +41,11 @@ jobs:
4141 --field content=@<(base64 -i $FILE_TO_COMMIT) \
4242 --field branch="$COMMIT_BRANCH" \
4343 --field sha="$(git rev-parse $COMMIT_BRANCH:$FILE_TO_COMMIT)"
44- gh pr create --title "[automation]: Update Flake dependencies" \
45- --body "This is an automated PR to update \`flake.lock\`" \
46- --label "flake.lock automation" \
47- --reviewer mrjones2014 \
48- --reviewer AndyTitu \
49- --base main --head $COMMIT_BRANCH
44+ if [ "$BRANCH_EXISTS" = "false" ]; then
45+ gh pr create --title "[automation]: Update Flake dependencies" \
46+ --body "This is an automated PR to update \`flake.lock\`" \
47+ --label "flake.lock automation" \
48+ --reviewer mrjones2014 \
49+ --base main --head $COMMIT_BRANCH
50+ fi
5051 fi
0 commit comments