Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

fix(docs): authenticate cloud pin dispatch via OIDC (#3528)

Francesco Bonacci986b6f257b1a
diff --git a/.github/workflows/cd-docs-pin-dispatch.yml b/.github/workflows/cd-docs-pin-dispatch.yml
index e4bb0d5258..86d7c39cc3 100644
--- a/.github/workflows/cd-docs-pin-dispatch.yml
+++ b/.github/workflows/cd-docs-pin-dispatch.yml
@@ -6,9 +6,9 @@ name: "CD: Docs Pin Dispatch"
# best-effort: repository_dispatch events can be dropped, so the cloud cron
# still converges the pin if a notification is lost.
#
-# The App token mirrors the identity cd-cua-driver-docs.yml already uses for
-# release-time repo writes; the same App installation covers trycua/cloud, and
-# the dispatch endpoint needs contents write on that repository.
+# The cross-repository App credential lives in AWS Secrets Manager. This
+# workflow assumes a main-only OIDC role, then downscopes the App token to
+# contents write on trycua/cloud for the dispatch request.
on:
push:
@@ -19,7 +19,13 @@ on:
- "docs/public/**"
workflow_dispatch:
-permissions: {}
+permissions:
+ contents: read
+ id-token: write
+
+env:
+ AWS_REGION: us-west-2
+ GITHUB_APP_SECRET: copybara/github-app
# Collapse bursts of docs merges into the newest dispatch; the cloud updater
# always resolves the latest docs commit itself, so older events are redundant.
@@ -31,17 +37,67 @@ jobs:
dispatch:
name: Notify trycua/cloud
runs-on: ubuntu-latest
+ timeout-minutes: 5
steps:
- - name: Generate GitHub App token
+ - name: Configure AWS credentials
+ uses: aws-actions/configure-aws-credentials@ff717079ee2060e4bcee96c4779b553acc87447c # v4
+ with:
+ role-to-assume: arn:aws:iam::296062593712:role/github-actions-docs-pin-cua
+ aws-region: ${{ env.AWS_REGION }}
+
+ - name: Load GitHub App credentials
+ id: github-app
+ shell: bash
+ run: |
+ set -euo pipefail
+ secret_json=$(aws secretsmanager get-secret-value \
+ --secret-id "${GITHUB_APP_SECRET}" \
+ --query SecretString \
+ --output text)
+ app_id=$(jq -er '.app_id | tostring' <<<"${secret_json}")
+ private_key=$(jq -er '.private_key' <<<"${secret_json}")
+ installation_id=$(jq -r '.installation_id // empty | tostring' <<<"${secret_json}")
+
+ mask() {
+ local value=${1//'%'/'%25'}
+ value=${value//$'\r'/'%0D'}
+ value=${value//$'\n'/'%0A'}
+ printf '::add-mask::%s\n' "${value}"
+ }
+ mask "${app_id}"
+ mask "${private_key}"
+ [[ -z "${installation_id}" ]] || mask "${installation_id}"
+
+ delimiter="DOCS_PIN_KEY_$(openssl rand -hex 16)"
+ {
+ printf 'app_id=%s\n' "${app_id}"
+ printf 'private_key<<%s\n%s\n%s\n' "${delimiter}" "${private_key}" "${delimiter}"
+ printf 'installation_id=%s\n' "${installation_id}"
+ } >> "${GITHUB_OUTPUT}"
+
+ - name: Mint GitHub App token
id: app-token
- uses: actions/create-github-app-token@v1
+ uses: actions/create-github-app-token@d72941d797fd3113feb6b93fd0dec494b13a2547 # v1
with:
- app-id: ${{ secrets.RELEASE_APP_ID }}
- private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
- owner: ${{ github.repository_owner }}
+ app-id: ${{ steps.github-app.outputs.app_id }}
+ private-key: ${{ steps.github-app.outputs.private_key }}
+ owner: trycua
repositories: cloud
permission-contents: write
+ - name: Verify GitHub App installation
+ if: steps.github-app.outputs.installation_id != ''
+ env:
+ ACTUAL_INSTALLATION_ID: ${{ steps.app-token.outputs.installation-id }}
+ EXPECTED_INSTALLATION_ID: ${{ steps.github-app.outputs.installation_id }}
+ shell: bash
+ run: |
+ set -euo pipefail
+ [[ "${ACTUAL_INSTALLATION_ID}" == "${EXPECTED_INSTALLATION_ID}" ]] || {
+ echo "GitHub App installation ID does not match copybara/github-app" >&2
+ exit 1
+ }
+
- name: Send repository_dispatch to cloud
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}