Skip to content

Commit c79e63d

Browse files
authored
Merge pull request #405 from ZeroGachis/feature/pla-2733
fix!: use GitHub App token to auto-trigger workflows on PRs
2 parents ded4e61 + 589a24b commit c79e63d

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

.github/workflows/create-gotoprod-pr.yml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,22 @@ jobs:
1616
contents: write
1717
pull-requests: write
1818
steps:
19+
- name: Generate GitHub App Token
20+
id: generate-token
21+
uses: actions/create-github-app-token@v1
22+
with:
23+
app-id: ${{ secrets.SW_BOT_APP_ID }}
24+
private-key: ${{ secrets.SW_BOT_APP_PRIVATE_KEY }}
25+
1926
- name: Checkout code
2027
uses: actions/checkout@v5
28+
with:
29+
token: ${{ steps.generate-token.outputs.token }}
2130

2231
- name: Create Pull Request
2332
uses: actions/github-script@v8
2433
with:
34+
github-token: ${{ steps.generate-token.outputs.token }}
2535
script: |
2636
const title = '🚀 Go to Production';
2737
const head = '${{ github.ref_name }}';
@@ -56,23 +66,23 @@ jobs:
5666
repo: context.repo.repo,
5767
pull_number: prNumber
5868
});
59-
69+
6070
// Collect both authors and committers
6171
const contributors = [];
6272
commits.data.forEach(commit => {
6373
// Add author if available and not a bot
6474
if (commit.author && commit.author.login && !commit.author.login.includes('[bot]')) {
6575
contributors.push(commit.author.login);
6676
}
67-
77+
6878
// Add committer if available, different from author, and not a bot
6979
if (commit.committer && commit.committer.login && !commit.committer.login.includes('[bot]')) {
7080
contributors.push(commit.committer.login);
7181
}
7282
});
73-
83+
7484
const uniqueContributors = [...new Set(contributors)];
75-
85+
7686
// Only request reviews if there are contributors
7787
if (uniqueContributors.length > 0) {
7888
try {
@@ -89,7 +99,7 @@ jobs:
8999
// Continue with the workflow - we still want their names in the PR
90100
}
91101
}
92-
102+
93103
return uniqueContributors;
94104
}
95105
@@ -110,7 +120,7 @@ jobs:
110120
`**Base**: \`${{ inputs.base }}\``,
111121
'### :mag_right: Changes',
112122
'### :busts_in_silhouette: Contributors',
113-
contributors.length > 0
123+
contributors.length > 0
114124
? '- ' + contributors.map(c => '@' + c).join('\n- ')
115125
: 'No human contributors identified'
116126
];

0 commit comments

Comments
 (0)