Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/pip/scripts/docker/examples/pytho…
Browse files Browse the repository at this point in the history
…n/assets/hello_world/setuptools-70.0.0
  • Loading branch information
timireland authored Dec 19, 2024
2 parents 159e12b + dd543a7 commit 1adac2b
Show file tree
Hide file tree
Showing 56 changed files with 738 additions and 430 deletions.
10 changes: 10 additions & 0 deletions .github/actions/setup/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: Make Config Action
description: Install dependencies and execute make config

runs:
using: composite
steps:
- name: Install dependencies and execute make config
shell: bash
run: |
scripts/setup/setup.sh
17 changes: 17 additions & 0 deletions .github/actions/tfsec/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: "TFSec Scan"
description: "Scan HCL using TFSec"
runs:
using: "composite"
steps:
- name: "TFSec Scan - Components"
shell: bash
run: |
for component in $(find infrastructure/terraform/components -mindepth 1 -type d); do
scripts/terraform/tfsec.sh $component
done
- name: "TFSec Scan - Modules"
shell: bash
run: |
for module in $(find infrastructure/terraform/modules -mindepth 1 -type d); do
scripts/terraform/tfsec.sh $module
done
24 changes: 24 additions & 0 deletions .github/workflows/manual-combine-dependabot-prs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Combine Dependabot PRs

on:
workflow_dispatch:

permissions:
contents: write
pull-requests: write
checks: read

jobs:
combine-prs:
runs-on: ubuntu-latest

steps:
- name: combine-prs
id: combine-prs
uses: github/[email protected]
with:
ci_required: false
labels: dependencies
pr_title: Combined Dependabot PRs
combine_branch_name: dependabotCombined
pr_body_header: Combined Dependabot PRs
55 changes: 55 additions & 0 deletions .github/workflows/scheduled-repository-template-sync.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Repository Template Sync

on:
schedule:
- cron: '0 0 1 * *'
workflow_dispatch:

permissions:
contents: write
pull-requests: write
checks: read

jobs:
update-external-repo:
runs-on: ubuntu-latest

steps:
- name: Check out the repository
uses: actions/checkout@v4

- name: Check out external repository
uses: actions/checkout@v4
with:
repository: NHSDigital/nhs-notify-repository-template
path: nhs-notify-repository-template
token: ${{ github.token }}

- name: Run syncronisation script
run: |
./scripts/githooks/sync-template-repo.sh
rm -Rf ./nhs-notify-repository-template
- name: Create Pull Request
if: ${{ !env.ACT }}
uses: peter-evans/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: Drift from template
branch: scheduledTemplateRepositorySync
delete-branch: true
title: '[Template Sync] Drift from template-repository remediation'
body: |
# Resultant drift from repository template
## Who should respond to this PR?
The team which owns the responsibility for this component repository. You may want to consult other contributors.
## How to progress this PR
The repositories guardians should review the contents of the PR and decide how to proceed, you may wish to back-out certain changes or accept them from the upstream `nhsdigital/nhs-notify-repository-template` repository.
If there are changes you do not wish to see again, it is recommended you add exclusions to `scripts/config/.repository-template-sync-ignore`.
labels: |
template
automation
draft: false
73 changes: 73 additions & 0 deletions .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# This workflow uses actions that are not certified by GitHub. They are provided
# by a third-party and are governed by separate terms of service, privacy
# policy, and support documentation.

name: Scorecard supply-chain security
on:
# For Branch-Protection check. Only the default branch is supported. See
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection
branch_protection_rule:
# To guarantee Maintained check is occasionally updated. See
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained
schedule:
- cron: '15 22 * * 5'
push:
branches: [ "main" ]

# Declare default permissions as read only.
permissions: read-all

jobs:
analysis:
name: Scorecard analysis
runs-on: ubuntu-latest
permissions:
# Needed to upload the results to code-scanning dashboard.
security-events: write
# Needed to publish results and get a badge (see publish_results below).
id-token: write
# Uncomment the permissions below if installing in a private repository.
# contents: read
# actions: read

steps:
- name: "Checkout code"
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
persist-credentials: false

- name: "Run analysis"
uses: ossf/scorecard-action@0864cf19026789058feabb7e87baa5f140aac736 # v2.3.1
with:
results_file: results.sarif
results_format: sarif
# (Optional) "write" PAT token. Uncomment the `repo_token` line below if:
# - you want to enable the Branch-Protection check on a *public* repository, or
# - you are installing Scorecard on a *private* repository
# To create the PAT, follow the steps in https://github.com/ossf/scorecard-action?tab=readme-ov-file#authentication-with-fine-grained-pat-optional.
# repo_token: ${{ secrets.SCORECARD_TOKEN }}

# Public repositories:
# - Publish results to OpenSSF REST API for easy access by consumers
# - Allows the repository to include the Scorecard badge.
# - See https://github.com/ossf/scorecard-action#publishing-results.
# For private repositories:
# - `publish_results` will always be set to `false`, regardless
# of the value entered here.
publish_results: false

# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
# format to the repository Actions tab.
- name: "Upload artifact"
uses: actions/upload-artifact@97a0fba1372883ab732affbe8f94b823f91727db # v3.pre.node20
with:
name: SARIF file
path: results.sarif
retention-days: 5

# Upload the results to GitHub's code scanning dashboard (optional).
# Commenting out will disable upload of results to your repo's Code Scanning dashboard
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@1b1aada464948af03b950897e5eb522f92603cc2 # v3.24.9
with:
sarif_file: results.sarif
40 changes: 40 additions & 0 deletions .github/workflows/stage-1-commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,55 @@ jobs:
fetch-depth: 0 # Full history is needed to compare branches
- name: "Check English usage"
uses: ./.github/actions/check-english-usage
detect-terraform-changes:
name: "Detect Terraform Changes"
runs-on: ubuntu-latest
outputs:
terraform_changed: ${{ steps.check.outputs.terraform_changed }}
steps:
- name: "Checkout code"
uses: actions/checkout@v4

- name: "Check for Terraform changes"
id: check
run: |
git fetch origin main || true # Ensure you have the latest main branch
CHANGED_FILES=$(git diff --name-only HEAD origin/main)
echo "Changed files: $CHANGED_FILES"
if echo "$CHANGED_FILES" | grep -qE '\.tf$'; then
echo "Terraform files have changed."
echo "terraform_changed=true" >> $GITHUB_OUTPUT
else
echo "No Terraform changes detected."
echo "terraform_changed=false" >> $GITHUB_OUTPUT
fi
lint-terraform:
name: "Lint Terraform"
runs-on: ubuntu-latest
timeout-minutes: 2
needs: detect-terraform-changes
if: needs.detect-terraform-changes.outputs.terraform_changed == 'true'
steps:
- name: "Checkout code"
uses: actions/checkout@v4
- name: "Lint Terraform"
uses: ./.github/actions/lint-terraform
tfsec:
name: "TFSec Scan"
runs-on: ubuntu-latest
timeout-minutes: 5
needs: detect-terraform-changes
if: needs.detect-terraform-changes.outputs.terraform_changed == 'true'
steps:
- name: "Checkout code"
uses: actions/checkout@v4
- name: "Setup ASDF"
uses: asdf-vm/actions/setup@v3
- name: "Perform Setup"
uses: ./.github/actions/setup
- name: "TFSec Scan"
uses: ./.github/actions/tfsec
count-lines-of-code:
name: "Count lines of code"
runs-on: ubuntu-latest
Expand Down
12 changes: 6 additions & 6 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# This file is for you! Please, updated to the versions agreed by your team.

terraform 1.9.1
pre-commit 3.6.0
nodejs 18.18.2
act 0.2.64
gitleaks 8.18.4
pre-commit 3.6.0
terraform 1.9.2
tfsec 1.28.10
vale 3.6.0

# ==============================================================================
# The section below is reserved for Docker image versions.
Expand All @@ -17,7 +17,7 @@ gitleaks 8.18.4
# docker/ghcr.io/nhs-england-tools/github-runner-image 20230909-321fd1e-rt@sha256:ce4fd6035dc450a50d3cbafb4986d60e77cb49a71ab60a053bb1b9518139a646 # SEE: https://github.com/nhs-england-tools/github-runner-image/pkgs/container/github-runner-image
# docker/hadolint/hadolint 2.12.0-alpine@sha256:7dba9a9f1a0350f6d021fb2f6f88900998a4fb0aaf8e4330aa8c38544f04db42 # SEE: https://hub.docker.com/r/hadolint/hadolint/tags
# docker/hashicorp/terraform 1.5.6@sha256:180a7efa983386a27b43657ed610e9deed9e6c3848d54f9ea9b6cb8a5c8c25f5 # SEE: https://hub.docker.com/r/hashicorp/terraform/tags
# docker/jdkato/vale v2.29.7@sha256:5ccfac574231b006284513ac3e4e9f38833989d83f2a68db149932c09de85149 # SEE: https://hub.docker.com/r/jdkato/vale/tags
# docker/jdkato/vale v3.6.0@sha256:0ef22c8d537f079633cfff69fc46f69a2196072f69cab1ab232e8a79a388e425 # SEE: https://hub.docker.com/r/jdkato/vale/tags
# docker/koalaman/shellcheck latest@sha256:e40388688bae0fcffdddb7e4dea49b900c18933b452add0930654b2dea3e7d5c # SEE: https://hub.docker.com/r/koalaman/shellcheck/tags
# docker/mstruebing/editorconfig-checker 2.7.1@sha256:dd3ca9ea50ef4518efe9be018d669ef9cf937f6bb5cfe2ef84ff2a620b5ddc24 # SEE: https://hub.docker.com/r/mstruebing/editorconfig-checker/tags
# docker/sonarsource/sonar-scanner-cli 5.0.1@sha256:494ecc3b5b1ee1625bd377b3905c4284e4f0cc155cff397805a244dee1c7d575 # SEE: https://hub.docker.com/r/sonarsource/sonar-scanner-cli/tags
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"**/CVS": true,
"**/Thumbs.db": true,
".devcontainer": true,
".github": true,
".github": false,
".vscode": false
}
}
Empty file.
19 changes: 11 additions & 8 deletions infrastructure/terraform/bin/terraform.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
##
# Set Script Version
##
readonly script_ver="1.8.0";
readonly script_ver="1.8.1";

##
# Standardised failure function
Expand Down Expand Up @@ -399,13 +399,16 @@ fi;
pushd "${component_path}";
readonly component_name=$(basename ${component_path});

# Check for presence of tfenv (https://github.com/kamatama41/tfenv)
# and a .terraform-version file. If both present, ensure required
# version of terraform for this component is installed automagically.
tfenv_bin="$(which tfenv 2>/dev/null)";
if [[ -n "${tfenv_bin}" && -x "${tfenv_bin}" && -f .terraform-version ]]; then
${tfenv_bin} install;
fi;
# install terraform
# verify terraform version matches .tool-versions
echo ${PWD}
tool_version=$(grep "terraform " .tool-versions | cut -d ' ' -f 2)
asdf plugin-add terraform && asdf install terraform "${tool_version}"
current_version=$(terraform --version | head -n 1 | cut -d 'v' -f 2)

if [ -z "${current_version}" ] || [ "${current_version}" != "${tool_version}" ]; then
error_and_die "Terraform version mismatch. Expected: ${tool_version}, Actual: ${current_version}"
fi

# Regardless of bootstrapping or not, we'll be using this string.
# If bootstrapping, we will fill it with variables,
Expand Down
1 change: 0 additions & 1 deletion infrastructure/terraform/bootstrap/.terraform-version

This file was deleted.

This file was deleted.

Loading

0 comments on commit 1adac2b

Please sign in to comment.