From 47ab19f412d8bde1fe2512f4b737cb1b2df89d27 Mon Sep 17 00:00:00 2001 From: William Pearce Date: Thu, 12 Nov 2026 20:51:56 +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/benchmark.yml | 22 ++++++++++++++++++++++ .github/workflows/pipeline.yml | 27 +++++++++++++++++++++++++-- README.md | 6 ++++-- 3 files changed, 51 insertions(+), 4 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index b2937e1..c3568f4 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -10,7 +10,29 @@ permissions: id-token: write jobs: + # A repo with no audit role yet (like the template repo) runs this job instead + # of the benchmark, and it says what to set up. Once AWS_AUDIT_ROLE_ARN is set, it skips. + benchmark-not-set-up: + name: "Benchmark skipped: set up AWS first" + if: vars.AWS_AUDIT_ROLE_ARN == '' + runs-on: ubuntu-latest + steps: + - name: Say what to set up + run: | + echo "::notice title=Benchmark skipped: set up AWS first::Set the AWS_AUDIT_ROLE_ARN variable to run the CIS benchmark. The run summary lists the steps." + cat >> "$GITHUB_STEP_SUMMARY" <<'EOF' + ## Benchmark skipped: this repo has no audit role yet + + The weekly Prowler CIS benchmark signs in to AWS as a read-only `security-audit` role: + + 1. Create the `security-audit` role with the trust policy from the Security section (Security section, Unit 1). + 2. **Settings → Secrets and variables → Actions → Variables:** add `AWS_AUDIT_ROLE_ARN`, set to that role's ARN. + + Then run it from **Actions → Benchmark → Run workflow**, or wait for Monday's run. + EOF + prowler: + if: vars.AWS_AUDIT_ROLE_ARN != '' runs-on: ubuntu-latest steps: # Pinned to a full commit SHA, not a version tag. Unit 3 explains why. diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 5d1a1ac..f6cbb53 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -130,10 +130,33 @@ jobs: path: image.tar.gz retention-days: 1 + # A repo with no AWS role yet (like the template repo) runs this job instead + # of deploy, and it says what to set up. Once AWS_DEPLOY_ROLE_ARN is set, it skips. + deploy-not-set-up: + name: "Deploy skipped: set up AWS first" + needs: build + if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request' && vars.AWS_DEPLOY_ROLE_ARN == '' + runs-on: ubuntu-latest + steps: + - name: Say what to set up + run: | + echo "::notice title=Deploy skipped: set up AWS first::Every gate passed. Set the AWS_DEPLOY_ROLE_ARN variable and create the production environment to deploy. The run summary lists the steps." + cat >> "$GITHUB_STEP_SUMMARY" <<'EOF' + ## Deploy skipped: this repo has no AWS role yet + + Every gate in the build job passed. The deploy job runs once AWS is set up: + + 1. **Stage 2:** `terraform -chdir=infra apply` builds the `capstone-deploy` role. + 2. **Settings → Secrets and variables → Actions → Variables:** add `AWS_DEPLOY_ROLE_ARN`, set to the output of `terraform -chdir=infra output -raw deploy_role_arn`. + 3. **Stage 3, Settings → Environments:** create `production`, with yourself as a required reviewer. + + Then re-run this workflow. The deploy waits for your approval, pushes the scanned image to ECR and deploys it with Systems Manager. + EOF + deploy: needs: build - # Only main, and never for a pull request. - if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request' + # Only main, never for a pull request, and only once AWS is set up. + if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request' && vars.AWS_DEPLOY_ROLE_ARN != '' runs-on: ubuntu-latest # Waits here for your approval. The AWS role only trusts this environment. environment: diff --git a/README.md b/README.md index 7d04508..8dc49e6 100644 --- a/README.md +++ b/README.md @@ -21,8 +21,10 @@ | **Cost** | About **$0.12 an hour** while it is up. `terraform -chdir=infra destroy` when you stop | | **Deliverable** | A live HTTPS app that only your pipeline can change, a README that explains every security decision, the evidence that it holds up, then an account with nothing running | -> [!WARNING] -> **GitHub Actions is switched off on this template repo.** There is no AWS account or `production` environment behind it. In **your** repo every push runs the gates, and every deploy waits for you. +> [!NOTE] +> [![CI/CD Pipeline](https://github.com/wjpearce-github/TechTwoForty-Capstone/actions/workflows/pipeline.yml/badge.svg)](https://github.com/wjpearce-github/TechTwoForty-Capstone/actions/workflows/pipeline.yml) +> +> **The pipeline runs on this template repo.** Open the [Actions tab](https://github.com/wjpearce-github/TechTwoForty-Capstone/actions) to see every gate run against this code and read the logs. There is no AWS account behind it, so instead of deploying, each run ends with a job called **Deploy skipped: set up AWS first** that lists what to set. In **your** repo, once `AWS_DEPLOY_ROLE_ARN` and the `production` environment are set up, every push runs the gates and every deploy waits for you. ## The big picture