Skip to content

Commit 7ebc0cc

Browse files
authored
Merge pull request #76 from NHSDigital/APM-7202-Github-bestpractices
APM-7202-Github-bestpractices
2 parents ede9930 + b849e1a commit 7ebc0cc

2 files changed

Lines changed: 54 additions & 57 deletions

File tree

.github/workflows/continuous-integration.yml

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -3,50 +3,50 @@ name: Build
33
on: push
44

55
jobs:
6-
build:
7-
name: build
8-
runs-on: ubuntu-latest
9-
steps:
10-
- name: Checkout
11-
uses: actions/checkout@v2
12-
with:
13-
fetch-depth: 0 # This causes all history to be fetched, which is required for calculate-version to function
14-
15-
- name: Install Python 3.10
16-
uses: actions/setup-python@v5
17-
with:
18-
python-version: "3.10"
19-
20-
- name: Update apt repositories
21-
run: sudo apt update
22-
23-
- name: Upgrade python packaging tools
24-
run: python -m pip install --upgrade pip setuptools wheel
25-
26-
- name: Install poetry
27-
run: pip install poetry
28-
29-
- name: Cache poetry packages
30-
uses: actions/cache@v4
31-
with:
32-
path: ~/.cache/pypoetry
33-
key: ${{ runner.os }}-build-cache-poetry-packages-${{ hashFiles('**/poetry.lock') }}
34-
35-
- name: Install python packages
36-
run: poetry install
37-
38-
- name: Set SPEC_VERSION env var
39-
run: echo ::set-env name=SPEC_VERSION::$(poetry run python scripts/calculate_version.py)
40-
env:
41-
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
42-
43-
- name: Create release (master only)
44-
id: create-release
45-
if: github.ref == 'refs/heads/master'
46-
uses: actions/create-release@v1
47-
continue-on-error: true
48-
env:
49-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50-
with:
51-
tag_name: ${{ env.SPEC_VERSION }}
52-
release_name: ${{ env.SPEC_VERSION }}
6+
build:
7+
name: build
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout
11+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
12+
with:
13+
fetch-depth: 0 # This causes all history to be fetched, which is required for calculate-version to function
14+
15+
- name: Install Python 3.10
16+
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
17+
with:
18+
python-version: "3.10"
19+
20+
- name: Update apt repositories
21+
run: sudo apt update
22+
23+
- name: Upgrade python packaging tools
24+
run: python -m pip install --upgrade pip setuptools wheel
25+
26+
- name: Install poetry
27+
run: pip install poetry
28+
29+
- name: Cache poetry packages
30+
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
31+
with:
32+
path: ~/.cache/pypoetry
33+
key: ${{ runner.os }}-build-cache-poetry-packages-${{ hashFiles('**/poetry.lock') }}
34+
35+
- name: Install python packages
36+
run: poetry install
37+
38+
- name: Set SPEC_VERSION env var
39+
run: echo ::set-env name=SPEC_VERSION::$(poetry run python scripts/calculate_version.py)
40+
env:
41+
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
42+
43+
- name: Create release (master only)
44+
id: create-release
45+
if: github.ref == 'refs/heads/master'
46+
uses: actions/create-release@0cb9c9b65d5d1901c1f53e5e66eaf4afd303e70e # v1.1.4
47+
continue-on-error: true
48+
env:
49+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50+
with:
51+
tag_name: ${{ env.SPEC_VERSION }}
52+
release_name: ${{ env.SPEC_VERSION }}

.github/workflows/sbom.yml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ jobs:
2424
contents: write
2525
steps:
2626
- name: Checkout
27-
uses: actions/checkout@v5
27+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2828

2929
- name: Setup Python 3.13
30-
uses: actions/setup-python@v5
30+
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
3131
with:
3232
python-version: "3.13"
3333

@@ -56,7 +56,7 @@ jobs:
5656
chmod +x syft
5757
5858
# Add to PATH for subsequent steps
59-
echo "$(pwd)" >> $GITHUB_PATH
59+
echo "$(pwd)" >> $GITHUB_PATH
6060
6161
- name: Create SBOM
6262
run: bash scripts/create-sbom.sh terraform python tflint
@@ -69,7 +69,7 @@ jobs:
6969
python .github/scripts/sbom_json_to_csv.py sbom.json SBOM_${REPO_NAME}.csv
7070
7171
- name: Upload SBOM CSV as artifact
72-
uses: actions/upload-artifact@v4
72+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
7373
with:
7474
name: sbom-csv
7575
path: SBOM_${{ github.event.repository.name }}.csv
@@ -81,18 +81,15 @@ jobs:
8181
- name: Scan SBOM for Vulnerabilities (JSON)
8282
run: |
8383
grype sbom:sbom.json -o json > grype-report.json
84-
85-
8684
8785
- name: Convert Grype JSON to CSV
8886
run: |
8987
pip install --upgrade pip
9088
REPO_NAME=$(basename $GITHUB_REPOSITORY)
9189
python .github/scripts/grype_json_to_csv.py grype-report.json grype-report-${REPO_NAME}.csv
9290
93-
9491
- name: Upload Vulnerability Report
95-
uses: actions/upload-artifact@v4
92+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
9693
with:
9794
name: grype-report
9895
path: grype-report-${{ github.event.repository.name }}.csv
@@ -104,7 +101,7 @@ jobs:
104101
python .github/scripts/sbom_packages_to_csv.py sbom.json $REPO_NAME
105102
106103
- name: Upload Package Inventory CSV
107-
uses: actions/upload-artifact@v4
104+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
108105
with:
109106
name: sbom-packages
110-
path: sbom-packages-${{ github.event.repository.name }}.csv
107+
path: sbom-packages-${{ github.event.repository.name }}.csv

0 commit comments

Comments
 (0)