1
1
name : " CI/CD pull request"
2
2
3
- # The total recommended execution time for the "CI/CD Pull Request" workflow is around 20 minutes.
4
-
5
3
on :
6
- push :
7
- branches :
8
- - " **"
9
4
pull_request :
10
- types : [opened, reopened]
5
+ types : [opened, reopened, synchronize ]
11
6
12
7
jobs :
13
8
metadata :
@@ -23,50 +18,22 @@ jobs:
23
18
python_version : ${{ steps.variables.outputs.python_version }}
24
19
terraform_version : ${{ steps.variables.outputs.terraform_version }}
25
20
version : ${{ steps.variables.outputs.version }}
26
- does_pull_request_exist : ${{ steps.pr_exists.outputs.does_pull_request_exist }}
27
21
steps :
28
22
- name : " Checkout code"
29
23
uses : actions/checkout@v4
30
24
- name : " Set CI/CD variables"
31
25
id : variables
32
26
run : |
33
27
datetime=$(date -u +'%Y-%m-%dT%H:%M:%S%z')
34
- BUILD_DATETIME=$datetime make version-create-effective-file
35
28
echo "build_datetime_london=$(TZ=Europe/London date --date=$datetime +'%Y-%m-%dT%H:%M:%S%z')" >> $GITHUB_OUTPUT
36
29
echo "build_datetime=$datetime" >> $GITHUB_OUTPUT
37
30
echo "build_timestamp=$(date --date=$datetime -u +'%Y%m%d%H%M%S')" >> $GITHUB_OUTPUT
38
31
echo "build_epoch=$(date --date=$datetime -u +'%s')" >> $GITHUB_OUTPUT
39
32
echo "nodejs_version=$(grep "^nodejs" .tool-versions | cut -f2 -d' ')" >> $GITHUB_OUTPUT
40
- echo "python_version=$(grep "^nodejs " .tool-versions | cut -f2 -d' ')" >> $GITHUB_OUTPUT
33
+ echo "python_version=$(grep "^python " .tool-versions | cut -f2 -d' ')" >> $GITHUB_OUTPUT
41
34
echo "terraform_version=$(grep "^terraform" .tool-versions | cut -f2 -d' ')" >> $GITHUB_OUTPUT
42
- echo "version=$(head -n 1 .version 2> /dev/null || echo unknown)" >> $GITHUB_OUTPUT
43
- - name : " Check if pull request exists for this branch"
44
- id : pr_exists
45
- env :
46
- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
47
- run : |
48
- branch_name=${GITHUB_HEAD_REF:-$(echo $GITHUB_REF | sed 's#refs/heads/##')}
49
- echo "Current branch is '$branch_name'"
50
- if gh pr list --head $branch_name | grep -q .; then
51
- echo "Pull request exists"
52
- echo "does_pull_request_exist=true" >> $GITHUB_OUTPUT
53
- else
54
- echo "Pull request doesn't exist"
55
- echo "does_pull_request_exist=false" >> $GITHUB_OUTPUT
56
- fi
57
- - name : " List variables"
58
- run : |
59
- export BUILD_DATETIME_LONDON="${{ steps.variables.outputs.build_datetime_london }}"
60
- export BUILD_DATETIME="${{ steps.variables.outputs.build_datetime }}"
61
- export BUILD_TIMESTAMP="${{ steps.variables.outputs.build_timestamp }}"
62
- export BUILD_EPOCH="${{ steps.variables.outputs.build_epoch }}"
63
- export NODEJS_VERSION="${{ steps.variables.outputs.nodejs_version }}"
64
- export PYTHON_VERSION="${{ steps.variables.outputs.python_version }}"
65
- export TERRAFORM_VERSION="${{ steps.variables.outputs.terraform_version }}"
66
- export VERSION="${{ steps.variables.outputs.version }}"
67
- export DOES_PULL_REQUEST_EXIST="${{ steps.pr_exists.outputs.does_pull_request_exist }}"
68
- make list-variables
69
- commit-stage : # Recommended maximum execution time is 2 minutes
35
+ echo "version=${GITHUB_REF}" >> $GITHUB_OUTPUT
36
+ commit-stage :
70
37
name : " Commit stage"
71
38
needs : [metadata]
72
39
uses : ./.github/workflows/stage-1-commit.yaml
79
46
terraform_version : " ${{ needs.metadata.outputs.terraform_version }}"
80
47
version : " ${{ needs.metadata.outputs.version }}"
81
48
secrets : inherit
82
- test-stage : # Recommended maximum execution time is 5 minutes
49
+ test-stage :
83
50
name : " Test stage"
84
- needs : [metadata, commit-stage ]
51
+ needs : [metadata]
85
52
uses : ./.github/workflows/stage-2-test.yaml
86
53
with :
87
54
build_datetime : " ${{ needs.metadata.outputs.build_datetime }}"
@@ -92,11 +59,10 @@ jobs:
92
59
terraform_version : " ${{ needs.metadata.outputs.terraform_version }}"
93
60
version : " ${{ needs.metadata.outputs.version }}"
94
61
secrets : inherit
95
- build-stage : # Recommended maximum execution time is 3 minutes
62
+ build-stage :
96
63
name : " Build stage"
97
64
needs : [metadata, test-stage]
98
65
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'))
100
66
with :
101
67
build_datetime : " ${{ needs.metadata.outputs.build_datetime }}"
102
68
build_timestamp : " ${{ needs.metadata.outputs.build_timestamp }}"
@@ -106,11 +72,10 @@ jobs:
106
72
terraform_version : " ${{ needs.metadata.outputs.terraform_version }}"
107
73
version : " ${{ needs.metadata.outputs.version }}"
108
74
secrets : inherit
109
- acceptance-stage : # Recommended maximum execution time is 10 minutes
75
+ acceptance-stage :
110
76
name : " Acceptance stage"
111
77
needs : [metadata, build-stage]
112
78
uses : ./.github/workflows/stage-4-acceptance.yaml
113
- if : needs.metadata.outputs.does_pull_request_exist == 'true' || (github.event_name == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'reopened'))
114
79
with :
115
80
build_datetime : " ${{ needs.metadata.outputs.build_datetime }}"
116
81
build_timestamp : " ${{ needs.metadata.outputs.build_timestamp }}"
0 commit comments