|
| 1 | +name: "4. CD | Deploy to PreProd" |
| 2 | + |
| 3 | +concurrency: |
| 4 | + group: preprod-deploy |
| 5 | + cancel-in-progress: false |
| 6 | + |
| 7 | +on: |
| 8 | + workflow_run: |
| 9 | + workflows: ["3. CD | Deploy to Test"] |
| 10 | + types: [completed] |
| 11 | + workflow_dispatch: |
| 12 | + inputs: |
| 13 | + ref: |
| 14 | + description: "dev-* tag to deploy to PreProd" |
| 15 | + required: true |
| 16 | + release_type: |
| 17 | + description: "rc|patch|minor|major" |
| 18 | + required: true |
| 19 | + default: "rc" |
| 20 | + reason: |
| 21 | + description: "Why are you doing a manual deployment?" |
| 22 | + required: true |
| 23 | + default: "To roll back to a previous commit" |
| 24 | + |
| 25 | +permissions: |
| 26 | + contents: read |
| 27 | + actions: read |
| 28 | + |
| 29 | +jobs: |
| 30 | + metadata: |
| 31 | + name: "Resolve ref + stale guard + release type" |
| 32 | + runs-on: ubuntu-latest |
| 33 | + outputs: |
| 34 | + ref: ${{ steps.resolver.outputs.this_ref }} |
| 35 | + this_sha: ${{ steps.resolver.outputs.this_sha }} |
| 36 | + latest_sha: ${{ steps.resolver.outputs.latest_test_sha }} |
| 37 | + release_type: ${{ steps.release_type.outputs.release_type }} |
| 38 | + |
| 39 | + env: |
| 40 | + TEST_WORKFLOW_ID: "190123511" # this will need updating if the workflow is recreated |
| 41 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 42 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 43 | + |
| 44 | + steps: |
| 45 | + - name: Checkout (full history & tags) |
| 46 | + uses: actions/checkout@v4 |
| 47 | + with: { fetch-depth: 0 } |
| 48 | + |
| 49 | + - name: Force HTTPS remote for act |
| 50 | + if: env.ACT == 'true' |
| 51 | + env: |
| 52 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 53 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 54 | + shell: bash |
| 55 | + run: | |
| 56 | + set -euo pipefail |
| 57 | + echo "::add-mask::${GITHUB_TOKEN}" |
| 58 | + git remote set-url origin "https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git" |
| 59 | + git ls-remote --tags origin >/dev/null |
| 60 | +
|
| 61 | + - name: Debug event |
| 62 | + if: env.ACT == 'true' |
| 63 | + run: | |
| 64 | + echo "GITHUB_EVENT_NAME=${GITHUB_EVENT_NAME}" |
| 65 | + echo "Payload:" && cat "$GITHUB_EVENT_PATH" || true |
| 66 | +
|
| 67 | + - name: Resolve THIS vs LATEST TEST + stale guard (auto only) |
| 68 | + id: resolver |
| 69 | + env: |
| 70 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 71 | + EVENT_NAME: ${{ github.event_name }} |
| 72 | + WORKFLOW_RUN_HEAD_SHA: ${{ github.event.workflow_run.head_sha }} |
| 73 | + MANUAL_REF: ${{ github.event.inputs.ref }} |
| 74 | + WORKFLOW_NAME: "3. CD | Deploy to Test" |
| 75 | + BRANCH: "main" |
| 76 | + LIMIT: "100" |
| 77 | + run: python3 scripts/workflow/pre-release_resolver.py |
| 78 | + |
| 79 | + - name: Resolve release_type (labels → default rc) |
| 80 | + id: release_type |
| 81 | + env: |
| 82 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 83 | + BRANCH: "main" |
| 84 | + AGGREGATE: "true" |
| 85 | + THIS_SHA: ${{ steps.resolver.outputs.this_sha }} |
| 86 | + LATEST_TEST_SHA: ${{ steps.resolver.outputs.latest_test_sha }} |
| 87 | + MANUAL_RELEASE_TYPE: ${{ github.event.inputs.release_type }} |
| 88 | + run: python3 scripts/workflow/release_type_resolver.py |
| 89 | + |
| 90 | + deploy: |
| 91 | + name: "Call base-deploy.yml (PreProd)" |
| 92 | + needs: [metadata] |
| 93 | + uses: ./.github/workflows/base-deploy.yml |
| 94 | + with: |
| 95 | + environment: preprod |
| 96 | + ref: ${{ needs.metadata.outputs.ref }} |
| 97 | + release_type: ${{ needs.metadata.outputs.release_type }} |
| 98 | + secrets: inherit |
0 commit comments