Skip to content

Commit a20a373

Browse files
ci: add GITHUB_TOKEN fallback when GitHub App secrets are unavailable (#167)
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
1 parent a804b84 commit a20a373

3 files changed

Lines changed: 29 additions & 11 deletions

File tree

.github/workflows/generate-command.yml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,22 @@ jobs:
8181
- name: Authenticate as GitHub App
8282
uses: actions/create-github-app-token@v3
8383
id: app-token
84+
continue-on-error: ${{ github.actor == 'dependabot[bot]' }}
8485
with:
8586
app-id: ${{ secrets.OCTAVIA_BOT_APP_ID }}
8687
private-key: ${{ secrets.OCTAVIA_BOT_PRIVATE_KEY }}
8788

89+
- name: Warn on GitHub App auth fallback
90+
if: steps.app-token.outcome == 'failure'
91+
run: |
92+
echo "::warning::GitHub App authentication failed (secrets may not be available in this context). Falling back to GITHUB_TOKEN."
93+
8894
- name: Post or append starting comment
8995
if: ${{ !inputs.dry_run && github.event.inputs.pr != '' }}
9096
id: start-comment
9197
uses: peter-evans/create-or-update-comment@v5
9298
with:
93-
token: ${{ steps.app-token.outputs.token }}
99+
token: ${{ steps.app-token.outputs.token || secrets.GITHUB_TOKEN }}
94100
issue-number: ${{ github.event.inputs.pr }}
95101
comment-id: ${{ github.event.inputs.comment-id || '' }}
96102
body: |
@@ -104,7 +110,7 @@ jobs:
104110
if: ${{ !inputs.dry_run && github.event.inputs.pr != '' }}
105111
id: pr-branch
106112
env:
107-
GH_TOKEN: ${{ steps.app-token.outputs.token }}
113+
GH_TOKEN: ${{ steps.app-token.outputs.token || secrets.GITHUB_TOKEN }}
108114
PR_NUMBER: ${{ github.event.inputs.pr }}
109115
run: |
110116
PR_JSON=$(gh api repos/${{ github.repository }}/pulls/${PR_NUMBER})
@@ -121,7 +127,7 @@ jobs:
121127
with:
122128
fetch-depth: 0
123129
ref: ${{ steps.pr-branch.outputs.head_ref || '' }}
124-
token: ${{ steps.app-token.outputs.token }}
130+
token: ${{ steps.app-token.outputs.token || secrets.GITHUB_TOKEN }}
125131

126132
- name: Install uv
127133
uses: astral-sh/setup-uv@v5
@@ -229,7 +235,7 @@ jobs:
229235
id: create-pr
230236
uses: peter-evans/create-pull-request@v6
231237
with:
232-
token: ${{ steps.app-token.outputs.token }}
238+
token: ${{ steps.app-token.outputs.token || secrets.GITHUB_TOKEN }}
233239
commit-message: "chore: regenerate SDK with Speakeasy"
234240
title: "chore: regenerate SDK with Speakeasy"
235241
body: |
@@ -246,14 +252,14 @@ jobs:
246252
|| github.event_name == 'schedule'
247253
) && steps.create-pr.outputs.pull-request-operation == 'created'
248254
env:
249-
GH_TOKEN: ${{ steps.app-token.outputs.token }}
255+
GH_TOKEN: ${{ steps.app-token.outputs.token || secrets.GITHUB_TOKEN }}
250256
run: gh pr merge ${{ steps.create-pr.outputs.pull-request-number }} --auto --squash
251257

252258
- name: Append success comment
253259
if: ${{ success() && !inputs.dry_run && github.event.inputs.pr != '' }}
254260
uses: peter-evans/create-or-update-comment@v5
255261
with:
256-
token: ${{ steps.app-token.outputs.token }}
262+
token: ${{ steps.app-token.outputs.token || secrets.GITHUB_TOKEN }}
257263
comment-id: ${{ steps.start-comment.outputs.comment-id }}
258264
reactions: hooray
259265
body: |
@@ -263,7 +269,7 @@ jobs:
263269
if: ${{ failure() && !inputs.dry_run && github.event.inputs.pr != '' }}
264270
uses: peter-evans/create-or-update-comment@v5
265271
with:
266-
token: ${{ steps.app-token.outputs.token }}
272+
token: ${{ steps.app-token.outputs.token || secrets.GITHUB_TOKEN }}
267273
comment-id: ${{ steps.start-comment.outputs.comment-id }}
268274
reactions: confused
269275
body: |

.github/workflows/pre-release-command.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,22 @@ jobs:
6161
- name: Authenticate as GitHub App
6262
uses: actions/create-github-app-token@v3
6363
id: app-token
64+
continue-on-error: ${{ github.actor == 'dependabot[bot]' }}
6465
with:
6566
app-id: ${{ secrets.OCTAVIA_BOT_APP_ID }}
6667
private-key: ${{ secrets.OCTAVIA_BOT_PRIVATE_KEY }}
6768

69+
- name: Warn on GitHub App auth fallback
70+
if: steps.app-token.outcome == 'failure'
71+
run: |
72+
echo "::warning::GitHub App authentication failed (secrets may not be available in this context). Falling back to GITHUB_TOKEN."
73+
6874
- name: Post starting comment
6975
if: ${{ inputs.pr != '' }}
7076
id: start-comment
7177
uses: peter-evans/create-or-update-comment@v5
7278
with:
73-
token: ${{ steps.app-token.outputs.token }}
79+
token: ${{ steps.app-token.outputs.token || secrets.GITHUB_TOKEN }}
7480
issue-number: ${{ inputs.pr }}
7581
comment-id: ${{ inputs.comment-id || '' }}
7682
body: |
@@ -85,7 +91,7 @@ jobs:
8591
if: ${{ inputs.pr != '' && inputs.ref == 'main' }}
8692
id: resolve-ref
8793
env:
88-
GH_TOKEN: ${{ steps.app-token.outputs.token }}
94+
GH_TOKEN: ${{ steps.app-token.outputs.token || secrets.GITHUB_TOKEN }}
8995
run: |
9096
PR_HEAD=$(gh pr view "${{ inputs.pr }}" --repo "${{ github.repository }}" --json headRefName -q '.headRefName')
9197
echo "ref=$PR_HEAD" >> "$GITHUB_OUTPUT"
@@ -142,7 +148,7 @@ jobs:
142148
if: ${{ always() && inputs.pr != '' }}
143149
uses: peter-evans/create-or-update-comment@v5
144150
with:
145-
token: ${{ steps.app-token.outputs.token }}
151+
token: ${{ steps.app-token.outputs.token || secrets.GITHUB_TOKEN }}
146152
issue-number: ${{ inputs.pr }}
147153
body: |
148154
> **Pre-Release Result:** ${{ job.status == 'success' && 'Published' || 'Failed' }}

.github/workflows/slash-command-dispatch.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,22 @@ jobs:
2020
- name: Authenticate as GitHub App
2121
uses: actions/create-github-app-token@v3
2222
id: app-token
23+
continue-on-error: ${{ github.actor == 'dependabot[bot]' }}
2324
with:
2425
app-id: ${{ secrets.OCTAVIA_BOT_APP_ID }}
2526
private-key: ${{ secrets.OCTAVIA_BOT_PRIVATE_KEY }}
2627

28+
- name: Warn on GitHub App auth fallback
29+
if: steps.app-token.outcome == 'failure'
30+
run: |
31+
echo "::warning::GitHub App authentication failed (secrets may not be available in this context). Falling back to GITHUB_TOKEN."
32+
2733
- name: Slash Command Dispatch
2834
id: dispatch
2935
uses: peter-evans/slash-command-dispatch@9bdcd7914ec1b75590b790b844aa3b8eee7c683a # v5.0.2
3036
with:
3137
repository: ${{ github.repository }}
32-
token: ${{ steps.app-token.outputs.token }}
38+
token: ${{ steps.app-token.outputs.token || secrets.GITHUB_TOKEN }}
3339
dispatch-type: workflow
3440
issue-type: pull-request
3541
commands: |

0 commit comments

Comments
 (0)