Skip to content

Commit 0b6c13f

Browse files
committed
PPHA-369: Add workflow for main branch
1 parent a9fc17f commit 0b6c13f

File tree

2 files changed

+107
-3
lines changed

2 files changed

+107
-3
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ name: "CI/CD pull request"
55
on:
66
push:
77
branches:
8-
- "**"
8+
- "!main"
99
pull_request:
10-
types: [opened, reopened, closed]
10+
types: [opened, reopened]
1111

1212
jobs:
1313
metadata:
@@ -65,6 +65,7 @@ jobs:
6565
export TERRAFORM_VERSION="${{ steps.variables.outputs.terraform_version }}"
6666
export VERSION="${{ steps.variables.outputs.version }}"
6767
export DOES_PULL_REQUEST_EXIST="${{ steps.pr_exists.outputs.does_pull_request_exist }}"
68+
export BRANCH_NAME="${{ github.head_ref }}"
6869
make list-variables
6970
commit-stage: # Recommended maximum execution time is 2 minutes
7071
name: "Commit stage"
@@ -96,7 +97,7 @@ jobs:
9697
name: "Build stage"
9798
needs: [metadata, test-stage]
9899
uses: ./.github/workflows/stage-3-build.yaml
99-
if: needs.metadata.outputs.does_pull_request_exist == 'true' || (github.event_name == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'reopened' || (github.event.action == 'closed' && github.event.pull_request.merged == true)))
100+
if: needs.metadata.outputs.does_pull_request_exist == 'true' || (github.event_name == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'reopened'))
100101
with:
101102
build_datetime: "${{ needs.metadata.outputs.build_datetime }}"
102103
build_timestamp: "${{ needs.metadata.outputs.build_timestamp }}"
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: "CI/CD pull request"
2+
3+
# The total recommended execution time for the "CI/CD Pull Request" workflow is around 20 minutes.
4+
5+
on:
6+
push:
7+
branches:
8+
- main
9+
10+
jobs:
11+
metadata:
12+
name: "Set CI/CD metadata"
13+
runs-on: ubuntu-latest
14+
timeout-minutes: 1
15+
outputs:
16+
build_datetime_london: ${{ steps.variables.outputs.build_datetime_london }}
17+
build_datetime: ${{ steps.variables.outputs.build_datetime }}
18+
build_timestamp: ${{ steps.variables.outputs.build_timestamp }}
19+
build_epoch: ${{ steps.variables.outputs.build_epoch }}
20+
nodejs_version: ${{ steps.variables.outputs.nodejs_version }}
21+
python_version: ${{ steps.variables.outputs.python_version }}
22+
terraform_version: ${{ steps.variables.outputs.terraform_version }}
23+
version: ${{ steps.variables.outputs.version }}
24+
steps:
25+
- name: "Checkout code"
26+
uses: actions/checkout@v5
27+
- name: "Set CI/CD variables"
28+
id: variables
29+
run: |
30+
datetime=$(date -u +'%Y-%m-%dT%H:%M:%S%z')
31+
BUILD_DATETIME=$datetime make version-create-effective-file
32+
echo "build_datetime_london=$(TZ=Europe/London date --date=$datetime +'%Y-%m-%dT%H:%M:%S%z')" >> $GITHUB_OUTPUT
33+
echo "build_datetime=$datetime" >> $GITHUB_OUTPUT
34+
echo "build_timestamp=$(date --date=$datetime -u +'%Y%m%d%H%M%S')" >> $GITHUB_OUTPUT
35+
echo "build_epoch=$(date --date=$datetime -u +'%s')" >> $GITHUB_OUTPUT
36+
echo "nodejs_version=$(grep "^nodejs\s" .tool-versions | cut -f2 -d' ')" >> $GITHUB_OUTPUT
37+
echo "python_version=$(grep "^python\s" .tool-versions | cut -f2 -d' ')" >> $GITHUB_OUTPUT
38+
echo "terraform_version=$(grep "^terraform\s" .tool-versions | cut -f2 -d' ')" >> $GITHUB_OUTPUT
39+
echo "version=$(head -n 1 .version 2> /dev/null || echo unknown)" >> $GITHUB_OUTPUT
40+
- name: "List variables"
41+
run: |
42+
export BUILD_DATETIME_LONDON="${{ steps.variables.outputs.build_datetime_london }}"
43+
export BUILD_DATETIME="${{ steps.variables.outputs.build_datetime }}"
44+
export BUILD_TIMESTAMP="${{ steps.variables.outputs.build_timestamp }}"
45+
export BUILD_EPOCH="${{ steps.variables.outputs.build_epoch }}"
46+
export NODEJS_VERSION="${{ steps.variables.outputs.nodejs_version }}"
47+
export PYTHON_VERSION="${{ steps.variables.outputs.python_version }}"
48+
export TERRAFORM_VERSION="${{ steps.variables.outputs.terraform_version }}"
49+
export VERSION="${{ steps.variables.outputs.version }}"
50+
export BRANCH_NAME="${{ github.head_ref }}"
51+
make list-variables
52+
commit-stage: # Recommended maximum execution time is 2 minutes
53+
name: "Commit stage"
54+
needs: [metadata]
55+
uses: ./.github/workflows/stage-1-commit.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+
test-stage: # Recommended maximum execution time is 5 minutes
66+
name: "Test stage"
67+
needs: [metadata, commit-stage]
68+
uses: ./.github/workflows/stage-2-test.yaml
69+
with:
70+
build_datetime: "${{ needs.metadata.outputs.build_datetime }}"
71+
build_timestamp: "${{ needs.metadata.outputs.build_timestamp }}"
72+
build_epoch: "${{ needs.metadata.outputs.build_epoch }}"
73+
nodejs_version: "${{ needs.metadata.outputs.nodejs_version }}"
74+
python_version: "${{ needs.metadata.outputs.python_version }}"
75+
terraform_version: "${{ needs.metadata.outputs.terraform_version }}"
76+
version: "${{ needs.metadata.outputs.version }}"
77+
secrets: inherit
78+
build-stage: # Recommended maximum execution time is 3 minutes
79+
name: "Build stage"
80+
needs: [metadata, test-stage]
81+
uses: ./.github/workflows/stage-3-build.yaml
82+
with:
83+
build_datetime: "${{ needs.metadata.outputs.build_datetime }}"
84+
build_timestamp: "${{ needs.metadata.outputs.build_timestamp }}"
85+
build_epoch: "${{ needs.metadata.outputs.build_epoch }}"
86+
nodejs_version: "${{ needs.metadata.outputs.nodejs_version }}"
87+
python_version: "${{ needs.metadata.outputs.python_version }}"
88+
terraform_version: "${{ needs.metadata.outputs.terraform_version }}"
89+
version: "${{ needs.metadata.outputs.version }}"
90+
secrets: inherit
91+
acceptance-stage: # Recommended maximum execution time is 10 minutes
92+
name: "Acceptance stage"
93+
needs: [metadata, build-stage]
94+
uses: ./.github/workflows/stage-4-acceptance.yaml
95+
with:
96+
build_datetime: "${{ needs.metadata.outputs.build_datetime }}"
97+
build_timestamp: "${{ needs.metadata.outputs.build_timestamp }}"
98+
build_epoch: "${{ needs.metadata.outputs.build_epoch }}"
99+
nodejs_version: "${{ needs.metadata.outputs.nodejs_version }}"
100+
python_version: "${{ needs.metadata.outputs.python_version }}"
101+
terraform_version: "${{ needs.metadata.outputs.terraform_version }}"
102+
version: "${{ needs.metadata.outputs.version }}"
103+
secrets: inherit

0 commit comments

Comments
 (0)