Skip to content

Commit dd46b26

Browse files
authored
Merge pull request #117 from NHSDigital/feature/terb-ELID-131-automated-deployment-networking-api
adding in improvements from meeting
2 parents 4382752 + 1a7cbef commit dd46b26

File tree

2 files changed

+31
-8
lines changed

2 files changed

+31
-8
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@ 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:
10-
types: [opened, reopened]
7+
types: [opened, synchronize, reopened]
118

129
jobs:
1310
metadata:
11+
if: github.event.pull_request.draft == false
1412
name: "Set CI/CD metadata"
1513
runs-on: ubuntu-latest
1614
timeout-minutes: 1
@@ -69,6 +67,7 @@ jobs:
6967
make list-variables
7068
commit-stage: # Recommended maximum execution time is 2 minutes
7169
name: "Commit stage"
70+
if: github.event.pull_request.draft == false
7271
needs: [metadata]
7372
uses: ./.github/workflows/stage-1-commit.yaml
7473
with:
@@ -82,6 +81,7 @@ jobs:
8281
secrets: inherit
8382
test-stage: # Recommended maximum execution time is 5 minutes
8483
name: "Test stage"
84+
if: github.event.pull_request.draft == false
8585
needs: [metadata, commit-stage]
8686
uses: ./.github/workflows/stage-2-test.yaml
8787
with:

.github/workflows/cicd-3-deploy.yaml

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ on:
1818
- test
1919
- preprod
2020
- prod
21+
release_type:
22+
description: "Version bump type (patch, minor, major)"
23+
required: false
24+
default: "patch"
25+
type: choice
26+
options:
27+
- patch
28+
- minor
29+
- major
2130

2231
jobs:
2332
metadata:
@@ -70,7 +79,7 @@ jobs:
7079
timeout-minutes: 10
7180
permissions:
7281
id-token: write
73-
contents: read
82+
contents: write
7483
steps:
7584
- name: "Setup Terraform"
7685
uses: hashicorp/setup-terraform@v3
@@ -124,7 +133,21 @@ jobs:
124133
else
125134
# Extract the version numbers
126135
IFS='.' read -r major minor patch <<< "${latest_tag#v}"
127-
patch=$((patch + 1))
136+
case "${{ github.event.inputs.release_type }}" in
137+
major)
138+
major=$((major + 1))
139+
minor=0
140+
patch=0
141+
;;
142+
minor)
143+
minor=$((minor + 1))
144+
patch=0
145+
;;
146+
patch|*)
147+
patch=$((patch + 1))
148+
;;
149+
esac
150+
128151
next_tag="v${major}.${minor}.${patch}"
129152
fi
130153
@@ -136,8 +159,8 @@ jobs:
136159
env:
137160
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
138161
with:
139-
tag_name: ${{ steps.next_tag.outputs.next_tag }}
140-
release_name: Release ${{ steps.next_tag.outputs.next_tag }}
162+
tag_name: ${{ steps.next_tag.outputs.tag }}
163+
release_name: Release ${{ steps.next_tag.outputs.tag }}
141164
body: |
142165
Auto-release created during deployment.
143166
draft: false

0 commit comments

Comments
 (0)