Skip to content

Commit 0473620

Browse files
authored
Merge pull request #638 from 1Password/scoot/maintenance/fix-nix-flake-update
[fix] fix update-flake-dependencies failures
2 parents 4311605 + ef9280d commit 0473620

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

.github/workflows/update-flake-dependencies.yml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,33 @@ jobs:
1313
with:
1414
egress-policy: audit
1515

16+
- name: Generate GitHub App installation token
17+
id: app-token
18+
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
19+
with:
20+
client-id: ${{ secrets.FLAKE_BOT_APP_ID }}
21+
private-key: ${{ secrets.FLAKE_BOT_APP_PRIVATE_KEY }}
22+
1623
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
24+
with:
25+
token: ${{ steps.app-token.outputs.token }}
1726
- uses: DeterminateSystems/nix-installer-action@ef8a148080ab6020fd15196c2084a2eea5ff2d25 # v22
1827
- uses: DeterminateSystems/magic-nix-cache-action@908b263ff629f4cc17666315b7fd3ec127c6244d # v14
1928
with:
2029
use-flakehub: false
2130
- name: Update flake.lock and create signed commit with flake.lock changes
2231
env:
23-
GITHUB_TOKEN: ${{ secrets.OP_BOT_TOKEN }}
32+
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
2433
FILE_TO_COMMIT: flake.lock
2534
COMMIT_BRANCH: automation/update-flake-dependencies
2635
COMMIT_MESSAGE: "chore(nix): Update Flake dependencies"
2736
run: |
2837
# fetch remote state
2938
git fetch
3039
# if branch exists on remote already
31-
BRANCH_EXISTS=false
3240
if git checkout "$COMMIT_BRANCH" > /dev/null 2>&1; then
33-
# pull changeshttps://github.com/1Password/shell-plugins/pull/595
41+
# pull changes
3442
git pull
35-
BRANCH_EXISTS=true
3643
else
3744
# otherwise, create the branch and push it to remote
3845
git checkout -b "$COMMIT_BRANCH"
@@ -48,11 +55,11 @@ jobs:
4855
--field content="$(base64 -w 0 $FILE_TO_COMMIT)" \
4956
--field branch="$COMMIT_BRANCH" \
5057
--field sha="$(git rev-parse $COMMIT_BRANCH:$FILE_TO_COMMIT)"
51-
if [ "$BRANCH_EXISTS" = "false" ]; then
58+
OPEN_PR_COUNT=$(gh pr list --head "$COMMIT_BRANCH" --state open --json number --jq 'length')
59+
if [ "$OPEN_PR_COUNT" -eq 0 ]; then
5260
gh pr create --title "[automation]: Update Flake dependencies" \
5361
--body "This is an automated PR to update \`flake.lock\`" \
5462
--label "flake.lock automation" \
55-
--reviewer mrjones2014 \
5663
--base main --head $COMMIT_BRANCH
5764
fi
5865
fi

0 commit comments

Comments
 (0)