Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7e0ff4c

Browse files
ci: use dedicated release App token to publish releases (backport 2.36) (#28555)
Backport of #28553 to `release/2.36`. ## Change Use a dedicated GitHub App token for the `Publish release` step: - Add a `Generate release App token` step using `secrets.RELEASE_APP_ID` / `secrets.RELEASE_APP_PRIVATE_KEY`. - Switch only that step's `GITHUB_TOKEN` to the minted App token. ## Required before merge (admin) 1. Create the release GitHub App (least privilege) and install it on `coder/coder`. 2. Configure `RELEASE_APP_ID` / `RELEASE_APP_PRIVATE_KEY`. 3. Add the App to the tag-create protection ruleset bypass list. Refs coder/security-automation#297.
1 parent 281d487 commit 7e0ff4c

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

.github/workflows/release.yaml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,22 @@ jobs:
541541
gcloud storage cp "./build/${detached_signature}" "gs://releases.coder.com/coder-cli/${version}/${cli_name}.asc"
542542
done
543543
544+
# Mint a short-lived installation token from the dedicated release
545+
# GitHub App. The default GITHUB_TOKEN (github-actions[bot]) cannot be
546+
# added to the "Auto-imported tag create protections" ruleset bypass
547+
# list, so `gh release create` fails to create the tag with a 403. The
548+
# App is added to that ruleset's bypass list as an Integration actor.
549+
- name: Generate release App token
550+
id: release_app_token
551+
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
552+
with:
553+
app-id: ${{ secrets.RELEASE_APP_ID }}
554+
private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
555+
# The App is installed at the org level, so resolve the org
556+
# installation (avoids a 404 on the per-repo installation lookup).
557+
owner: ${{ github.repository_owner }}
558+
repositories: coder
559+
544560
- name: Publish release
545561
run: |
546562
set -euo pipefail
@@ -579,7 +595,9 @@ jobs:
579595
--release-notes-file "$CODER_RELEASE_NOTES_FILE" \
580596
"${files[@]}"
581597
env:
582-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
598+
# Use the dedicated release App token (github-actions[bot] is blocked
599+
# from creating tags by the tag-create protection ruleset).
600+
GITHUB_TOKEN: ${{ steps.release_app_token.outputs.token }}
583601
CODER_GPG_RELEASE_KEY_BASE64: ${{ secrets.GPG_RELEASE_KEY_BASE64 }}
584602
VERSION: ${{ steps.version.outputs.version }}
585603
CREATED_LATEST_TAG: ${{ steps.build_docker.outputs.created_latest_tag }}

0 commit comments

Comments
 (0)