Skip to content

Commit 0d4ebfd

Browse files
committed
PPHA-369: Add main branch workflow to test and build container
1 parent af8c7a9 commit 0d4ebfd

File tree

2 files changed

+80
-3
lines changed

2 files changed

+80
-3
lines changed

.github/workflows/cicd-1-pull-request.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ name: "CI/CD pull request"
33
# The total recommended execution time for the "CI/CD Pull Request" workflow is around 20 minutes.
44

55
on:
6-
push:
7-
branches:
8-
- "**"
96
pull_request:
107
types: [opened, reopened]
118

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: 'CI/CD main branch'
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
jobs:
8+
metadata:
9+
name: 'Set CI/CD metadata'
10+
runs-on: ubuntu-latest
11+
timeout-minutes: 1
12+
outputs:
13+
build_datetime: ${{ steps.variables.outputs.build_datetime }}
14+
build_timestamp: ${{ steps.variables.outputs.build_timestamp }}
15+
build_epoch: ${{ steps.variables.outputs.build_epoch }}
16+
nodejs_version: ${{ steps.variables.outputs.nodejs_version }}
17+
python_version: ${{ steps.variables.outputs.python_version }}
18+
terraform_version: ${{ steps.variables.outputs.terraform_version }}
19+
version: ${{ steps.variables.outputs.version }}
20+
tag: ${{ steps.variables.outputs.tag }}
21+
steps:
22+
- name: 'Checkout code'
23+
uses: actions/checkout@v5
24+
- name: 'Set CI/CD variables'
25+
id: variables
26+
run: |
27+
datetime=$(date -u +'%Y-%m-%dT%H:%M:%S%z')
28+
echo "build_datetime=$datetime" >> $GITHUB_OUTPUT
29+
echo "build_timestamp=$(date --date=$datetime -u +'%Y%m%d%H%M%S')" >> $GITHUB_OUTPUT
30+
echo "build_epoch=$(date --date=$datetime -u +'%s')" >> $GITHUB_OUTPUT
31+
echo "nodejs_version=$(grep "^nodejs" .tool-versions | cut -f2 -d' ')" >> $GITHUB_OUTPUT
32+
echo "python_version=$(grep "^python" .tool-versions | cut -f2 -d' ')" >> $GITHUB_OUTPUT
33+
echo "terraform_version=$(grep "^terraform" .tool-versions | cut -f2 -d' ')" >> $GITHUB_OUTPUT
34+
echo "version=${GITHUB_REF}"
35+
36+
# Scan the commit
37+
commit-stage:
38+
name: 'Commit stage'
39+
needs: [metadata]
40+
uses: ./.github/workflows/stage-1-commit.yaml
41+
with:
42+
build_datetime: '${{ needs.metadata.outputs.build_datetime }}'
43+
build_timestamp: '${{ needs.metadata.outputs.build_timestamp }}'
44+
build_epoch: '${{ needs.metadata.outputs.build_epoch }}'
45+
nodejs_version: '${{ needs.metadata.outputs.nodejs_version }}'
46+
python_version: '${{ needs.metadata.outputs.python_version }}'
47+
terraform_version: '${{ needs.metadata.outputs.terraform_version }}'
48+
version: '${{ needs.metadata.outputs.version }}'
49+
secrets: inherit
50+
51+
# Test the integrated code
52+
test-stage:
53+
name: 'Test stage'
54+
needs: [metadata]
55+
uses: ./.github/workflows/stage-2-test.yaml
56+
with:
57+
build_datetime: '${{ needs.metadata.outputs.build_datetime }}'
58+
build_timestamp: '${{ needs.metadata.outputs.build_timestamp }}'
59+
build_epoch: '${{ needs.metadata.outputs.build_epoch }}'
60+
nodejs_version: '${{ needs.metadata.outputs.nodejs_version }}'
61+
python_version: '${{ needs.metadata.outputs.python_version }}'
62+
terraform_version: '${{ needs.metadata.outputs.terraform_version }}'
63+
version: '${{ needs.metadata.outputs.version }}'
64+
secrets: inherit
65+
66+
# Build the final artefact with the integrated code
67+
build-stage: # Recommended maximum execution time is 3 minutes
68+
name: 'Build stage'
69+
needs: [metadata, commit-stage, test-stage]
70+
uses: ./.github/workflows/stage-3-build.yaml
71+
with:
72+
build_datetime: '${{ needs.metadata.outputs.build_datetime }}'
73+
build_timestamp: '${{ needs.metadata.outputs.build_timestamp }}'
74+
build_epoch: '${{ needs.metadata.outputs.build_epoch }}'
75+
nodejs_version: '${{ needs.metadata.outputs.nodejs_version }}'
76+
python_version: '${{ needs.metadata.outputs.python_version }}'
77+
terraform_version: '${{ needs.metadata.outputs.terraform_version }}'
78+
version: '${{ needs.metadata.outputs.version }}'
79+
commit_sha: '${{ github.sha }}'
80+
secrets: inherit

0 commit comments

Comments
 (0)