|
| 1 | +# Exact-tree public promotion for a previously reviewed Castiron candidate. |
| 2 | +# Keep this wrapper thin: policy and copy mechanics live in the pinned monorepo writer. |
| 3 | +# CASTIRON_PROMOTION_ENABLED is a repository/org variable because the job guard |
| 4 | +# runs before GitHub attaches the protected environment. |
| 5 | +# The protected castiron-promotion environment supplies the container/Azure |
| 6 | +# variables plus the monorepo-reader and openai-sdks App private keys. |
| 7 | +name: Castiron promotion |
| 8 | + |
| 9 | +on: |
| 10 | + workflow_dispatch: |
| 11 | + inputs: |
| 12 | + candidate_id: |
| 13 | + description: SHA-256 ID of the approved Castiron candidate |
| 14 | + required: true |
| 15 | + type: string |
| 16 | + preflight_contract_sha256: |
| 17 | + description: SHA-256 digest of the published promotion preflight contract |
| 18 | + required: true |
| 19 | + type: string |
| 20 | + |
| 21 | +permissions: |
| 22 | + contents: read |
| 23 | + id-token: write |
| 24 | + |
| 25 | +concurrency: |
| 26 | + group: castiron-promotion-${{ github.repository }} |
| 27 | + cancel-in-progress: false |
| 28 | + |
| 29 | +jobs: |
| 30 | + promote: |
| 31 | + name: open exact-tree draft PR |
| 32 | + # Keep the draft-stack pin inert until it is replaced with the merged SHA |
| 33 | + # and admins explicitly enable the protected promotion environment. |
| 34 | + if: >- |
| 35 | + vars.CASTIRON_PROMOTION_ENABLED == 'true' && |
| 36 | + github.repository == 'openai/openai-python' && |
| 37 | + github.ref == 'refs/heads/main' |
| 38 | + runs-on: ubuntu-latest |
| 39 | + timeout-minutes: 30 |
| 40 | + environment: castiron-promotion |
| 41 | + permissions: |
| 42 | + contents: read |
| 43 | + id-token: write |
| 44 | + |
| 45 | + steps: |
| 46 | + # This credential is read-only and exists only to fetch the pinned private |
| 47 | + # monorepo writer. Do not reuse the SDK write token for checkout. |
| 48 | + - name: Mint monorepo reader token |
| 49 | + id: monorepo-token |
| 50 | + uses: actions/create-github-app-token@d72941d797fd3113feb6b93fd0dec494b13a2547 # v1.12.0 |
| 51 | + with: |
| 52 | + app-id: ${{ vars.CASTIRON_MONOREPO_READER_APP_ID }} |
| 53 | + private-key: ${{ secrets.CASTIRON_MONOREPO_READER_APP_PRIVATE_KEY }} |
| 54 | + owner: openai |
| 55 | + repositories: openai |
| 56 | + permission-contents: read |
| 57 | + |
| 58 | + - name: Check out pinned Castiron writer |
| 59 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 |
| 60 | + with: |
| 61 | + repository: openai/openai |
| 62 | + # Replace this draft-stack SHA with the merged monorepo SHA before enabling. |
| 63 | + ref: 7479907537bdc3f2cd63290d8d5320cbdfd5ca56 |
| 64 | + path: openai |
| 65 | + token: ${{ steps.monorepo-token.outputs.token }} |
| 66 | + persist-credentials: false |
| 67 | + |
| 68 | + - name: Set up Python for the pinned writer |
| 69 | + uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 |
| 70 | + with: |
| 71 | + python-version: "3.12" |
| 72 | + |
| 73 | + - name: Add pinned monorepo tools to PATH |
| 74 | + run: echo "$GITHUB_WORKSPACE/openai/project/dotslash-gen/bin" >> "$GITHUB_PATH" |
| 75 | + |
| 76 | + - name: Azure login |
| 77 | + uses: azure/login@532459ea530d8321f2fb9bb10d1e0bcf23869a43 # v3.0.0 |
| 78 | + with: |
| 79 | + client-id: ${{ vars.CASTIRON_AZURE_CLIENT_ID }} |
| 80 | + tenant-id: ${{ vars.CASTIRON_AZURE_TENANT_ID }} |
| 81 | + allow-no-subscriptions: true |
| 82 | + |
| 83 | + # Mint this immediately before the writer runs. The writer independently |
| 84 | + # verifies the installation scope and expected openai-sdks[bot] identity. |
| 85 | + - name: Mint SDK promotion token |
| 86 | + id: sdk-token |
| 87 | + uses: actions/create-github-app-token@d72941d797fd3113feb6b93fd0dec494b13a2547 # v1.12.0 |
| 88 | + with: |
| 89 | + app-id: 3705508 # openai-sdks |
| 90 | + private-key: ${{ secrets.OPENAI_SDKS_APP_PRIVATE_KEY }} |
| 91 | + owner: openai |
| 92 | + repositories: | |
| 93 | + openai-python |
| 94 | + openai-python-internal |
| 95 | + permission-actions: read |
| 96 | + permission-contents: write |
| 97 | + permission-members: read |
| 98 | + permission-metadata: read |
| 99 | + permission-pull-requests: write |
| 100 | + |
| 101 | + - name: Open exact-tree public draft PR |
| 102 | + working-directory: openai |
| 103 | + env: |
| 104 | + GH_TOKEN: ${{ steps.sdk-token.outputs.token }} |
| 105 | + CANDIDATE_ID: ${{ inputs.candidate_id }} |
| 106 | + PREFLIGHT_CONTRACT_SHA256: ${{ inputs.preflight_contract_sha256 }} |
| 107 | + CASTIRON_CONTAINER_URI: ${{ vars.CASTIRON_CONTAINER_URI }} |
| 108 | + ACTOR: ${{ github.actor }} |
| 109 | + run: | |
| 110 | + bazel run //api/sdk-worker:castiron_candidate_public_pr_writer -- \ |
| 111 | + --target openai-python \ |
| 112 | + --container-uri "$CASTIRON_CONTAINER_URI" \ |
| 113 | + --candidate-id "$CANDIDATE_ID" \ |
| 114 | + --preflight-contract-sha256 "$PREFLIGHT_CONTRACT_SHA256" \ |
| 115 | + --actor "$ACTOR" \ |
| 116 | + --execute |
0 commit comments