Skip to content

Commit 0bbaee6

Browse files
authored
Migrate release workflow auth to deploy key + per-repo FG PAT (#336)
* Migrate release workflow auth to deploy key + per-repo FG PAT Switches actions/checkout from token-auth (shared PAT) to ssh-key (per-repo deploy key), and the gh CLI GITHUB_TOKEN from the shared PAT to a per-repo FG PAT. Both reads pull from per-repo Secrets Manager secrets (deploy-key + fg-pat). Depends on per-repo SM secrets being created on the bot account; do not merge before then or the workflow will fail at next release run. * Combine label add into gh pr create to avoid PAT scope failure
1 parent 5a0e673 commit 0bbaee6

2 files changed

Lines changed: 16 additions & 17 deletions

File tree

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

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,19 @@ jobs:
2929
with:
3030
role-to-assume: ${{ secrets.RELEASE_WORKFLOW_ACCESS_TOKEN_ROLE_ARN }}
3131
aws-region: us-west-2
32-
# Retrieve the Access Token from Secrets Manager
33-
- name: Retrieve secret from AWS Secrets Manager
32+
# Retrieve the per-repo deploy key + FG PAT from Secrets Manager
33+
- name: Retrieve secrets from AWS Secrets Manager
3434
uses: aws-actions/aws-secretsmanager-get-secrets@3a411b6ec5cace3d626412dd917e7bfeac242cfa #v3.0.0
3535
with:
3636
secret-ids: |
37-
AWS_SECRET, ${{ secrets.RELEASE_WORKFLOW_ACCESS_TOKEN_NAME }}
38-
parse-json-secrets: true
39-
# Checkout a full clone of the repo
37+
DEPLOY_KEY, prod/devops/aws-dotnet-messaging-deploy-key
38+
FG_PAT, prod/devops/aws-dotnet-messaging-fg-pat
39+
# Checkout a full clone of the repo using the deploy key (push runs over SSH)
4040
- name: Checkout
4141
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #v6.0.2
4242
with:
4343
fetch-depth: '0'
44-
token: ${{ env.AWS_SECRET_TOKEN }}
44+
ssh-key: ${{ env.DEPLOY_KEY }}
4545
# Install .NET8 which is needed for AutoVer
4646
- name: Setup .NET 8.0
4747
uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 #v5.2.0
@@ -94,8 +94,7 @@ jobs:
9494
# Create the Release PR and label it
9595
- name: Create Pull Request
9696
env:
97-
GITHUB_TOKEN: ${{ env.AWS_SECRET_TOKEN }}
97+
GITHUB_TOKEN: ${{ env.FG_PAT }}
9898
run: |
99-
pr_url="$(gh pr create --title "${{ steps.read-release-name.outputs.VERSION }}" --body "${{ steps.read-changelog.outputs.CHANGELOG }}" --base dev --head ${{ steps.create-release-branch.outputs.BRANCH }})"
10099
gh label create "Release PR" --description "A Release PR that includes versioning and changelog changes" -c "#FF0000" -f
101-
gh pr edit $pr_url --add-label "Release PR"
100+
pr_url="$(gh pr create --title "${{ steps.read-release-name.outputs.VERSION }}" --label "Release PR" --body "${{ steps.read-changelog.outputs.CHANGELOG }}" --base dev --head ${{ steps.create-release-branch.outputs.BRANCH }})"

.github/workflows/sync-main-dev.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,20 @@ jobs:
3131
with:
3232
role-to-assume: ${{ secrets.RELEASE_WORKFLOW_ACCESS_TOKEN_ROLE_ARN }}
3333
aws-region: us-west-2
34-
# Retrieve the Access Token from Secrets Manager
35-
- name: Retrieve secret from AWS Secrets Manager
34+
# Retrieve the per-repo deploy key + FG PAT from Secrets Manager
35+
- name: Retrieve secrets from AWS Secrets Manager
3636
uses: aws-actions/aws-secretsmanager-get-secrets@3a411b6ec5cace3d626412dd917e7bfeac242cfa #v3.0.0
3737
with:
3838
secret-ids: |
39-
AWS_SECRET, ${{ secrets.RELEASE_WORKFLOW_ACCESS_TOKEN_NAME }}
40-
parse-json-secrets: true
41-
# Checkout a full clone of the repo
39+
DEPLOY_KEY, prod/devops/aws-dotnet-messaging-deploy-key
40+
FG_PAT, prod/devops/aws-dotnet-messaging-fg-pat
41+
# Checkout a full clone of the repo using the deploy key (push runs over SSH)
4242
- name: Checkout code
4343
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #v6.0.2
4444
with:
4545
ref: dev
4646
fetch-depth: 0
47-
token: ${{ env.AWS_SECRET_TOKEN }}
47+
ssh-key: ${{ env.DEPLOY_KEY }}
4848
# Install .NET8 which is needed for AutoVer
4949
- name: Setup .NET 8.0
5050
uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 #v5.2.0
@@ -86,7 +86,7 @@ jobs:
8686
# Create the GitHub Release
8787
- name: Create GitHub Release
8888
env:
89-
GITHUB_TOKEN: ${{ env.AWS_SECRET_TOKEN }}
89+
GITHUB_TOKEN: ${{ env.FG_PAT }}
9090
run: |
9191
gh release create "${{ steps.read-tag-name.outputs.TAG }}" --title "${{ steps.read-release-name.outputs.VERSION }}" --notes "${{ steps.read-changelog.outputs.CHANGELOG }}"
9292
# Delete the `releases/next-release` branch
@@ -105,7 +105,7 @@ jobs:
105105
github.event.pull_request.base.ref == 'dev'
106106
runs-on: ubuntu-latest
107107
steps:
108-
# Checkout a full clone of the repo
108+
# Checkout a full clone of the repo using the deploy key (push runs over SSH)
109109
- name: Checkout code
110110
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #v6.0.2
111111
with:

0 commit comments

Comments
 (0)