From c6d4160242feffa2feafdb8f4833903c04fad4e0 Mon Sep 17 00:00:00 2001 From: William Pearce Date: Thu, 12 Nov 2026 20:52:03 +0000 Subject: [PATCH] Run the pipeline on the template repo GitHub Actions is now switched on for this repo. The jobs that need AWS (deploy, and the weekly benchmark where there is one) skip themselves when no AWS role is set up, and a clearly named job says what to set instead of failing. The README's 'Actions is switched off' warning is replaced with a pointer to the Actions tab. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/pipeline.yml | 24 +++++++++++++++++++++++- README.md | 10 ++++++---- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index ed26f05..0f84205 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -58,14 +58,36 @@ jobs: permissions: id-token: write contents: read + env: + # Phase 5: replace ACCOUNT_ID with your 12-digit AWS account number. + DEPLOY_ROLE: arn:aws:iam::ACCOUNT_ID:role/github-deploy steps: - uses: actions/checkout@v4 + # Until ACCOUNT_ID is replaced (like on the template repo), this step + # says what to set up and the two steps after it skip. + - name: "Deploy skipped: set up AWS first" + if: contains(env.DEPLOY_ROLE, 'ACCOUNT_ID') + run: | + echo "::notice title=Deploy skipped: set up AWS first::Every gate passed. Make the github-deploy role, then replace ACCOUNT_ID in DEPLOY_ROLE to deploy. The run summary lists the steps." + cat >> "$GITHUB_STEP_SUMMARY" <<'EOF' + ## Deploy skipped: the deploy role is not filled in yet + + Every gate in the build job passed. To let the deploy job sign in to AWS: + + 1. **Phase 4:** make the `github-deploy` role, trusted through OIDC. + 2. **Phase 5:** in `.github/workflows/pipeline.yml`, replace `ACCOUNT_ID` in the `DEPLOY_ROLE` line with your 12-digit AWS account number. + + Push that change and this job signs in to AWS with no stored keys. + EOF + - name: Configure AWS credentials (OIDC) + if: ${{ !contains(env.DEPLOY_ROLE, 'ACCOUNT_ID') }} uses: aws-actions/configure-aws-credentials@v4 with: - role-to-assume: arn:aws:iam::ACCOUNT_ID:role/github-deploy + role-to-assume: ${{ env.DEPLOY_ROLE }} aws-region: eu-west-2 - name: Deploy + if: ${{ !contains(env.DEPLOY_ROLE, 'ACCOUNT_ID') }} run: echo "push image to ECR + update service here" diff --git a/README.md b/README.md index 7b6363e..abd7260 100644 --- a/README.md +++ b/README.md @@ -21,8 +21,10 @@ | **Runs on** | GitHub Actions, your capstone repo, and an AWS account for the deploy role | | **Deliverable** | A pipeline that gates every change on tests and scans, deploys through a short-lived role with no stored keys, and is a required check on `main` | -> [!WARNING] -> **GitHub Actions is switched off on this template repo.** There is no AWS account behind it, so the deploy job could never sign in. In **your** repo the pipeline runs on every push and pull request. +> [!NOTE] +> [![CI/CD Pipeline](https://github.com/wjpearce-github/TechTwoForty-CICD/actions/workflows/pipeline.yml/badge.svg)](https://github.com/wjpearce-github/TechTwoForty-CICD/actions/workflows/pipeline.yml) +> +> **The pipeline runs on this template repo.** Open the [Actions tab](https://github.com/wjpearce-github/TechTwoForty-CICD/actions) to see build, test and the three scans run against this code. There is no AWS account behind it, so `ACCOUNT_ID` is still a placeholder and the deploy job stops at a step called **Deploy skipped: set up AWS first**. In **your** repo, once you replace `ACCOUNT_ID` (Phase 5), the pipeline runs and deploys on every push and pull request. ## The big picture @@ -89,7 +91,7 @@ aws iam create-role --role-name github-deploy --assume-role-policy-document file The role has **no permissions** yet, on purpose. The capstone builds the real, least-privilege deploy role. ### Phase 5 · The deploy job -Replace `ACCOUNT_ID` in the `role-to-assume` line before you push. `needs: build` is the gate: if anything upstream is red, deploy never runs. +Replace `ACCOUNT_ID` in the `DEPLOY_ROLE` line before you push. Until you do, the deploy job skips the AWS steps and says what is missing. `needs: build` is the gate: if anything upstream is red, deploy never runs. ### Phase 6 · Close the gate Merge the pipeline PR. Then Settings, Branches, the `main` rule, **Require status checks to pass**: search for and select `build`. From now on the merge button stays grey until the pipeline is green. @@ -105,7 +107,7 @@ Merge the pipeline PR. Then Settings, Branches, the `main` rule, **Require statu | Mistake | What happens | The fix | |---|---|---| -| Forgetting to replace `ACCOUNT_ID` | The credentials step fails | Put your account number in both places | +| Forgetting to replace `ACCOUNT_ID` | The deploy job stops at **Deploy skipped: set up AWS first** | Put your account number in the trust policy and the `DEPLOY_ROLE` line | | Missing `permissions: id-token: write` | OIDC cannot get a token | It sits on the deploy job | | Trust policy subject typo | `Not authorized to perform sts:AssumeRoleWithWebIdentity` | Print the IDs again and compare, character by character | | Committing straight to main | Rejected: main is protected | Branch, push, PR, merge |