An open-source, faster Devin alternative
TypeScript
ci: add temporary Worker secret ferry runner (#1009)
Mohamed Habibaf81d371baf7
diff --git a/.github/workflows/ferry-worker-secrets-to-infisical.yml b/.github/workflows/ferry-worker-secrets-to-infisical.ymlnew file mode 100644index 00000000..9b84bdcb--- /dev/null+++ b/.github/workflows/ferry-worker-secrets-to-infisical.yml@@ -0,0 +1,120 @@+# Temporary Track E recovery workflow. Delete after every live Worker secret is+# verified in Infisical and the ferry versions have been removed.+name: Ferry Worker secrets to Infisical (temporary)++on:+ workflow_dispatch:+ inputs:+ mode:+ description: Compare only, or create missing values and verify+ required: true+ default: compare+ type: choice+ options:+ - compare+ - migrate++permissions:+ contents: read+ id-token: write++concurrency:+ group: ferry-worker-secrets-to-infisical+ cancel-in-progress: false++jobs:+ ferry:+ runs-on: ubuntu-latest+ timeout-minutes: 10+ env:+ INFISICAL_IDENTITY_ID: ${{ vars.INFISICAL_IDENTITY_ID }}+ INFISICAL_PROJECT_SLUG: ${{ vars.INFISICAL_PROJECT_SLUG }}+ FERRY_TRIGGER: ${{ secrets.SECRET_FERRY_TRIGGER }}+ CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}+ CF_ACCOUNT_ID: b8f23cb87a7a6c64040d3134643da448+ API_EDGE_WORKER: opencomputer-edge-prod+ API_EDGE_LIVE_VERSION: 9655a72f-976d-4bba-bdcd-3b32ad416ac1+ API_EDGE_FERRY_VERSION: 9913a725-685e-4b7c-8ff1-2ef0bcf9d93b+ API_EDGE_URL: https://opencomputer-edge-prod.mo-b8f.workers.dev/__ops/track-e/secret-ferry+ LOG_TAIL_FERRY_VERSION: dbbf2840-27ed-46e6-bb91-9cf633caed9e+ LOG_TAIL_URL: https://dbbf2840-opencomputer-log-tail-prod.mo-b8f.workers.dev/__ops/track-e/secret-ferry++ steps:+ - name: Verify pinned Cloudflare versions+ shell: bash+ run: |+ set -Eeuo pipefail+ : "${CLOUDFLARE_API_TOKEN:?missing CLOUDFLARE_API_TOKEN}"+ : "${FERRY_TRIGGER:?missing SECRET_FERRY_TRIGGER}"+ : "${INFISICAL_IDENTITY_ID:?missing INFISICAL_IDENTITY_ID}"+ : "${INFISICAL_PROJECT_SLUG:?missing INFISICAL_PROJECT_SLUG}"++ deployment="$(+ curl --proto '=https' --tlsv1.2 --fail --silent --show-error + --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" + "https://api.cloudflare.com/client/v4/accounts/$CF_ACCOUNT_ID/workers/scripts/$API_EDGE_WORKER/deployments"+ )"+ jq --exit-status + --arg live "$API_EDGE_LIVE_VERSION" + --arg ferry "$API_EDGE_FERRY_VERSION" '+ .success == true and+ (.result.deployments | max_by(.created_on).versions) as $versions and+ ($versions | length) == 2 and+ any($versions[]; .version_id == $live and .percentage == 100) and+ any($versions[]; .version_id == $ferry and .percentage == 0)+ ' <<<"$deployment" >/dev/null++ versions="$(+ curl --proto '=https' --tlsv1.2 --fail --silent --show-error + --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" + "https://api.cloudflare.com/client/v4/accounts/$CF_ACCOUNT_ID/workers/scripts/opencomputer-log-tail-prod/versions"+ )"+ jq --exit-status --arg ferry "$LOG_TAIL_FERRY_VERSION" '+ .success == true and any(.result.items[]; .id == $ferry)+ ' <<<"$versions" >/dev/null++ - name: Compare, migrate, and verify exact values+ shell: bash+ env:+ FERRY_MODE: ${{ inputs.mode }}+ run: |+ set -Eeuo pipefail+ umask 077++ oidc_response="$(+ curl --proto '=https' --tlsv1.2 --fail --silent --show-error + --header "Authorization: Bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" + "${ACTIONS_ID_TOKEN_REQUEST_URL}&audience=https%3A%2F%2Fgithub.com%2Fdiggerhq"+ )"+ oidc_jwt="$(jq --exit-status --raw-output '.value | strings | select(length > 0)' <<<"$oidc_response")"+ printf '::add-mask::%s\n' "$oidc_jwt"+ unset oidc_response++ login_response="$(+ jq --null-input + --arg identityId "$INFISICAL_IDENTITY_ID" + --arg jwt "$oidc_jwt" + '{identityId: $identityId, jwt: $jwt}' |+ curl --proto '=https' --tlsv1.2 --fail --silent --show-error + --request POST + --header 'Content-Type: application/json' + --data-binary @- + https://app.infisical.com/api/v1/auth/oidc-auth/login+ )"+ unset oidc_jwt+ infisical_token="$(jq --exit-status --raw-output '.accessToken | strings | select(length > 0)' <<<"$login_response")"+ printf '::add-mask::%s\n' "$infisical_token"+ unset login_response++ revoke_token() {+ jq --null-input --arg accessToken "$infisical_token" '{accessToken: $accessToken}' |+ curl --proto '=https' --tlsv1.2 --silent --show-error + --request POST + --header 'Content-Type: application/json' + --data-binary @- + --output /dev/null + https://app.infisical.com/api/v1/auth/token/revoke || true+ }+ trap revoke_token EXIT++ invoke() {+ local operation="$1"+ local expected="$2"+ local url="$3"+ shift 3+ local result+ result="$(+ jq --null-input + --arg accessToken "$infisical_token" + --arg trigger "$FERRY_TRIGGER" + --arg mode "$FERRY_MODE" + '{accessToken: $accessToken, trigger: $trigger, mode: $mode}' |+ curl --proto '=https' --tlsv1.2 --fail-with-body --silent --show-error + --request POST + --header 'Content-Type: application/json' + "$@" + --data-binary @- + "$url"+ )"+ jq --exit-status + --arg operation "$operation" + --arg mode "$FERRY_MODE" + --argjson expected "$expected" '+ .ok == true and+ .operation == $operation and+ .mode == $mode and+ .expected == $expected+ ' <<<"$result" >/dev/null+ jq '{operation, mode, expected, equal, missing, created, verified}' <<<"$result"+ }++ invoke + track-e-opencomputer-api-edge-v1 + 24 + "$API_EDGE_URL" + --header "Cloudflare-Workers-Version-Overrides: $API_EDGE_WORKER=\"$API_EDGE_FERRY_VERSION\""+ invoke + track-e-opencomputer-log-tail-v1 + 1 + "$LOG_TAIL_URL"