mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-16 05:01:03 +03:00
ci(deploy): mint short-lived cloudflare tokens from the token issuer
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
# Mints a short-lived Cloudflare token for the current release job from the token issuer
|
||||
# Mints a short-lived Cloudflare token for the current job from the token issuer
|
||||
# (anomalyco/secrets). Run after aws-actions/configure-aws-credentials has assumed
|
||||
# arn:aws:iam::604439173067:role/github/opencode-release: the Lambda identifies the role from the
|
||||
# SigV4 signature and mints only the `opencode/release` token. No repo, stage, permission or TTL
|
||||
# is sent in the request, and the token is pinned to the runner's IP for 30 minutes.
|
||||
# arn:aws:iam::604439173067:role/github/opencode-<stage> (release, dev or production): the Lambda
|
||||
# identifies the role from the SigV4 signature and mints only that stage's token. No repo, stage,
|
||||
# permission or TTL is sent in the request, and the token is pinned to the runner's IP.
|
||||
#
|
||||
# Step-scoped by default: the token goes to $GITHUB_OUTPUT and only steps that list
|
||||
# `CLOUDFLARE_API_TOKEN: ${{ steps.<id>.outputs.token }}` in their env receive it.
|
||||
|
||||
@@ -38,12 +38,18 @@ jobs:
|
||||
role-session-name: opencode-${{ github.run_id }}
|
||||
aws-region: us-east-1
|
||||
|
||||
- name: Read deploy secrets
|
||||
uses: aws-actions/aws-secretsmanager-get-secrets@2297f9a879480a9e3af9b293ed15c70caf8e1c88 # v3.0.2
|
||||
with:
|
||||
secret-ids: CLOUDFLARE_API_TOKEN,opencode/${{ github.ref_name }}/CLOUDFLARE_API_TOKEN
|
||||
parse-json-secrets: false
|
||||
# A 15-minute token for this stage's Workers only, minted by the token issuer (anomalyco/secrets) from the role
|
||||
# above. It is a step output, so only the Deploy step gets it.
|
||||
- name: Cloudflare token
|
||||
id: cloudflare-token
|
||||
run: bash .github/release/cloudflare-token.sh
|
||||
env:
|
||||
CLOUDFLARE_TOKEN_URL: ${{ vars.CLOUDFLARE_TOKEN_URL }}
|
||||
|
||||
# wrangler.jsonc has no account id, and the token can't list accounts.
|
||||
- name: Deploy
|
||||
working-directory: services/files
|
||||
run: bun run deploy --env ${{ github.ref_name == 'production' && 'production' || 'dev' }}
|
||||
env:
|
||||
CLOUDFLARE_ACCOUNT_ID: 15d29c8639fd3733b1b5486a2acfd968
|
||||
CLOUDFLARE_API_TOKEN: ${{ steps.cloudflare-token.outputs.token }}
|
||||
|
||||
@@ -42,12 +42,16 @@ jobs:
|
||||
role-session-name: opencode-${{ github.run_id }}
|
||||
aws-region: us-east-1
|
||||
|
||||
- name: Read deploy secrets
|
||||
uses: aws-actions/aws-secretsmanager-get-secrets@2297f9a879480a9e3af9b293ed15c70caf8e1c88 # v3.0.2
|
||||
with:
|
||||
secret-ids: CLOUDFLARE_API_TOKEN,opencode/${{ github.ref_name }}/CLOUDFLARE_API_TOKEN
|
||||
parse-json-secrets: false
|
||||
# A 15-minute token for this stage's Workers only, minted by the token issuer (anomalyco/secrets) from the role
|
||||
# above. It is a step output, so only the Deploy step gets it.
|
||||
- name: Cloudflare token
|
||||
id: cloudflare-token
|
||||
run: bash .github/release/cloudflare-token.sh
|
||||
env:
|
||||
CLOUDFLARE_TOKEN_URL: ${{ vars.CLOUDFLARE_TOKEN_URL }}
|
||||
|
||||
- name: Deploy
|
||||
working-directory: services/site
|
||||
run: bunx cf deploy --prebuilt --mode ${{ github.ref_name }}
|
||||
env:
|
||||
CLOUDFLARE_API_TOKEN: ${{ steps.cloudflare-token.outputs.token }}
|
||||
|
||||
@@ -37,12 +37,18 @@ jobs:
|
||||
role-session-name: opencode-${{ github.run_id }}
|
||||
aws-region: us-east-1
|
||||
|
||||
- name: Read deploy secrets
|
||||
uses: aws-actions/aws-secretsmanager-get-secrets@2297f9a879480a9e3af9b293ed15c70caf8e1c88 # v3.0.2
|
||||
with:
|
||||
secret-ids: CLOUDFLARE_API_TOKEN,opencode/production/CLOUDFLARE_API_TOKEN
|
||||
parse-json-secrets: false
|
||||
# A 15-minute token for the production Workers only, minted by the token issuer (anomalyco/secrets) from the role
|
||||
# above. It is a step output, so only the Deploy step gets it.
|
||||
- name: Cloudflare token
|
||||
id: cloudflare-token
|
||||
run: bash .github/release/cloudflare-token.sh
|
||||
env:
|
||||
CLOUDFLARE_TOKEN_URL: ${{ vars.CLOUDFLARE_TOKEN_URL }}
|
||||
|
||||
# wrangler.jsonc has no account id, and the token can't list accounts.
|
||||
- name: Deploy
|
||||
working-directory: services/update
|
||||
run: bun run deploy
|
||||
env:
|
||||
CLOUDFLARE_ACCOUNT_ID: 15d29c8639fd3733b1b5486a2acfd968
|
||||
CLOUDFLARE_API_TOKEN: ${{ steps.cloudflare-token.outputs.token }}
|
||||
|
||||
@@ -32,18 +32,21 @@ jobs:
|
||||
role-session-name: opencode-${{ github.run_id }}
|
||||
aws-region: us-east-1
|
||||
|
||||
- name: Read deploy secrets
|
||||
uses: aws-actions/aws-secretsmanager-get-secrets@2297f9a879480a9e3af9b293ed15c70caf8e1c88 # v3.0.2
|
||||
with:
|
||||
secret-ids: CLOUDFLARE_API_TOKEN,opencode/${{ github.ref_name }}/CLOUDFLARE_API_TOKEN
|
||||
parse-json-secrets: false
|
||||
# A 15-minute token for this stage's Workers only, minted by the token issuer (anomalyco/secrets) from the role
|
||||
# above. It is a step output, so only the Deploy step gets it.
|
||||
- name: Cloudflare token
|
||||
id: cloudflare-token
|
||||
run: bash .github/release/cloudflare-token.sh
|
||||
env:
|
||||
CLOUDFLARE_TOKEN_URL: ${{ vars.CLOUDFLARE_TOKEN_URL }}
|
||||
|
||||
# The GitHub App secrets are read here, not in the step above, so only this step ever has them. They reach cf
|
||||
# through a file in the runner's temp directory, never argv, and the file is removed when the step ends.
|
||||
# The GitHub App secrets are read here, so only this step ever has them. They reach cf through a file in the
|
||||
# runner's temp directory, never argv, and the file is removed when the step ends.
|
||||
- name: Deploy
|
||||
working-directory: services/legacy
|
||||
env:
|
||||
STAGE: ${{ github.ref_name }}
|
||||
CLOUDFLARE_API_TOKEN: ${{ steps.cloudflare-token.outputs.token }}
|
||||
# An explicit bash runs with pipefail, so a failed secret read fails the step.
|
||||
shell: bash
|
||||
run: |
|
||||
@@ -80,18 +83,19 @@ jobs:
|
||||
role-session-name: opencode-${{ github.run_id }}
|
||||
aws-region: us-east-1
|
||||
|
||||
- name: Read deploy secrets
|
||||
uses: aws-actions/aws-secretsmanager-get-secrets@2297f9a879480a9e3af9b293ed15c70caf8e1c88 # v3.0.2
|
||||
with:
|
||||
secret-ids: CLOUDFLARE_API_TOKEN,opencode/${{ github.ref_name }}/CLOUDFLARE_API_TOKEN
|
||||
parse-json-secrets: false
|
||||
- name: Cloudflare token
|
||||
id: cloudflare-token
|
||||
run: bash .github/release/cloudflare-token.sh
|
||||
env:
|
||||
CLOUDFLARE_TOKEN_URL: ${{ vars.CLOUDFLARE_TOKEN_URL }}
|
||||
|
||||
# The Workers' secrets are read here, not in the step above, so only this step ever has them. They reach cf
|
||||
# through files in the runner's temp directory, never argv, and are removed when the step ends.
|
||||
# The Workers' secrets are read here, so only this step ever has them. They reach cf through files in the
|
||||
# runner's temp directory, never argv, and are removed when the step ends.
|
||||
- name: Deploy
|
||||
working-directory: services/data
|
||||
env:
|
||||
STAGE: ${{ github.ref_name }}
|
||||
CLOUDFLARE_API_TOKEN: ${{ steps.cloudflare-token.outputs.token }}
|
||||
# An explicit bash runs with pipefail, so a failed secret read fails the step.
|
||||
shell: bash
|
||||
run: |
|
||||
|
||||
Reference in New Issue
Block a user