Skip to content

Commit 20835f7

Browse files
committed
workflows/periodic-merges: use nix-backport app's token when merging branches
This will allow GitHub to run actions on those commits, specifically Eval action. Currently as these merges are commited by `github-actions`, Eval doesn't run on the commits. ie, https://github.com/NixOS/nixpkgs/actions/runs/12646467735/job/35237397411?pr=371701 failed due to NixOS@fa2d66f commit was done by github-actions. With this every periodic merge will be authored and commited by the nix-backports bot. We can reuse the bot here as they have similar perms (NixOS/org#38)
1 parent 538b8b4 commit 20835f7

File tree

3 files changed

+35
-12
lines changed

3 files changed

+35
-12
lines changed

.github/workflows/periodic-merge-24h.yml

+12-4
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ permissions:
2020

2121
jobs:
2222
periodic-merge:
23-
permissions:
24-
contents: write # for devmasx/merge-branch to merge branches
25-
pull-requests: write # for peter-evans/create-or-update-comment to create or update comment
2623
if: github.repository_owner == 'NixOS'
2724
runs-on: ubuntu-24.04
2825
strategy:
@@ -39,20 +36,31 @@ jobs:
3936
into: staging-24.11
4037
name: ${{ matrix.pairs.from }} → ${{ matrix.pairs.into }}
4138
steps:
39+
# Use a GitHub App to create the PR so that CI gets triggered
40+
# The App is scoped to Repository > Contents and Pull Requests: write for Nixpkgs
41+
# Same app as in backport.yml
42+
- uses: actions/create-github-app-token@c1a285145b9d317df6ced56c09f525b5c2b6f755 # v1.11.1
43+
id: app-token
44+
with:
45+
app-id: ${{ vars.BACKPORT_APP_ID }}
46+
private-key: ${{ secrets.BACKPORT_PRIVATE_KEY }}
4247
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
48+
with:
49+
token: ${{ steps.app-token.outputs.token }}
4350

4451
- name: ${{ matrix.pairs.from }} → ${{ matrix.pairs.into }}
4552
uses: devmasx/merge-branch@854d3ac71ed1e9deb668e0074781b81fdd6e771f # 1.4.0
4653
with:
4754
type: now
4855
from_branch: ${{ matrix.pairs.from }}
4956
target_branch: ${{ matrix.pairs.into }}
50-
github_token: ${{ secrets.GITHUB_TOKEN }}
57+
github_token: ${{ steps.app-token.outputs.token }}
5158

5259
- name: Comment on failure
5360
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
5461
if: ${{ failure() }}
5562
with:
63+
token: ${{ steps.app-token.outputs.token }}
5664
issue-number: 105153
5765
body: |
5866
Periodic merge from `${{ matrix.pairs.from }}` into `${{ matrix.pairs.into }}` has [failed](https://github.com/NixOS/nixpkgs/actions/runs/${{ github.run_id }}).

.github/workflows/periodic-merge-6h.yml

+12-4
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ permissions:
2020

2121
jobs:
2222
periodic-merge:
23-
permissions:
24-
contents: write # for devmasx/merge-branch to merge branches
25-
pull-requests: write # for peter-evans/create-or-update-comment to create or update comment
2623
if: github.repository_owner == 'NixOS'
2724
runs-on: ubuntu-24.04
2825
strategy:
@@ -39,20 +36,31 @@ jobs:
3936
into: staging
4037
name: ${{ matrix.pairs.from }} → ${{ matrix.pairs.into }}
4138
steps:
39+
# Use a GitHub App to create the PR so that CI gets triggered
40+
# The App is scoped to Repository > Contents and Pull Requests: write for Nixpkgs
41+
# Same app as in backport.yml
42+
- uses: actions/create-github-app-token@c1a285145b9d317df6ced56c09f525b5c2b6f755 # v1.11.1
43+
id: app-token
44+
with:
45+
app-id: ${{ vars.BACKPORT_APP_ID }}
46+
private-key: ${{ secrets.BACKPORT_PRIVATE_KEY }}
4247
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
48+
with:
49+
token: ${{ steps.app-token.outputs.token }}
4350

4451
- name: ${{ matrix.pairs.from }} → ${{ matrix.pairs.into }}
4552
uses: devmasx/merge-branch@854d3ac71ed1e9deb668e0074781b81fdd6e771f # 1.4.0
4653
with:
4754
type: now
4855
from_branch: ${{ matrix.pairs.from }}
4956
target_branch: ${{ matrix.pairs.into }}
50-
github_token: ${{ secrets.GITHUB_TOKEN }}
57+
github_token: ${{ steps.app-token.outputs.token }}
5158

5259
- name: Comment on failure
5360
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
5461
if: ${{ failure() }}
5562
with:
63+
token: ${{ steps.app-token.outputs.token }}
5664
issue-number: 105153
5765
body: |
5866
Periodic merge from `${{ matrix.pairs.from }}` into `${{ matrix.pairs.into }}` has [failed](https://github.com/NixOS/nixpkgs/actions/runs/${{ github.run_id }}).

.github/workflows/periodic-merge-haskell-updates.yml

+11-4
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,22 @@ permissions:
2222

2323
jobs:
2424
periodic-merge:
25-
permissions:
26-
contents: write # for devmasx/merge-branch to merge branches
27-
pull-requests: write # for peter-evans/create-or-update-comment to create or update comment
2825
if: github.repository_owner == 'NixOS'
2926
runs-on: ubuntu-24.04
3027
name: git merge-base master staging → haskell-updates
3128
steps:
29+
# Use a GitHub App to create the PR so that CI gets triggered
30+
# The App is scoped to Repository > Contents and Pull Requests: write for Nixpkgs
31+
# Same app as in backport.yml
32+
- uses: actions/create-github-app-token@c1a285145b9d317df6ced56c09f525b5c2b6f755 # v1.11.1
33+
id: app-token
34+
with:
35+
app-id: ${{ vars.BACKPORT_APP_ID }}
36+
private-key: ${{ secrets.BACKPORT_PRIVATE_KEY }}
3237
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
3338
with:
3439
fetch-depth: 0
40+
token: ${{ steps.app-token.outputs.token }}
3541

3642
# Note: If we want to do something similar for more branches, we can move this into a
3743
# separate job, so we can use the matrix strategy again.
@@ -48,12 +54,13 @@ jobs:
4854
type: now
4955
head_to_merge: ${{ steps.find_merge_base_step.outputs.merge_base }}
5056
target_branch: haskell-updates
51-
github_token: ${{ secrets.GITHUB_TOKEN }}
57+
github_token: ${{ steps.app-token.outputs.token }}
5258

5359
- name: Comment on failure
5460
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
5561
if: ${{ failure() }}
5662
with:
63+
token: ${{ steps.app-token.outputs.token }}
5764
issue-number: 367709
5865
body: |
5966
Periodic merge from `${{ steps.find_merge_base_step.outputs.merge_base }}` into `haskell-updates` has [failed](https://github.com/NixOS/nixpkgs/actions/runs/${{ github.run_id }}).

0 commit comments

Comments
 (0)