Skip to content

Commit 7ba0841

Browse files
authored
[PRMP-1493] Add branch or tagged version deployments to pre-prod
1 parent f1d201d commit 7ba0841

File tree

1 file changed

+17
-20
lines changed

1 file changed

+17
-20
lines changed
Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,57 @@
1-
# .github/workflows/terraform-dev
2-
name: 'Deploy and Version Main to Pre-Prod'
1+
name: 'Deploy to Pre-Prod'
32

43
on:
54
workflow_dispatch:
5+
inputs:
6+
branch_or_tag:
7+
description: "Which branch or tag do you want to deploy to pre-prod?"
8+
required: true
9+
type: string
10+
default: main
611

712
permissions:
813
pull-requests: write
914
id-token: write # This is required for requesting the JWT
1015
contents: read # This is required for actions/checkout
1116

1217
jobs:
13-
1418
tag_and_release:
1519
runs-on: ubuntu-latest
1620
outputs:
17-
tag: ${{steps.versioning.outputs.tag}}
18-
new_tag: ${{steps.versioning.outputs.new_tag}}
21+
version: ${{ steps.versioning.outputs.tag || github.event.inputs.branch_or_tag }}
1922
permissions: write-all
2023

2124
steps:
22-
23-
- uses: actions/checkout@v4
25+
- name: Checkout main
26+
if: ${{ github.event.inputs.branch_or_tag == 'main' }}
27+
uses: actions/checkout@v4
2428
with:
2529
ref: main
2630
fetch-depth: '0'
2731

2832
- name: Bump version and push tag
33+
if: ${{ github.event.inputs.branch_or_tag == 'main' }}
2934
id: versioning
3035
uses: anothrNick/[email protected]
3136
env:
3237
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3338
WITH_V: false
3439
DEFAULT_BUMP: patch
35-
40+
3641
- name: View outputs
3742
run: |
38-
echo Current tag: ${{steps.versioning.outputs.tag}}
39-
echo New tag: ${{steps.versioning.outputs.new_tag}}
43+
echo Deploying branch or tagged version to pre-prod: ${{ steps.versioning.outputs.tag || github.event.inputs.branch_or_tag }}
4044
4145
terraform_process:
4246
runs-on: ubuntu-latest
4347
needs: ['tag_and_release']
4448
environment: pre-prod
49+
4550
steps:
46-
# Checkout the repository to the GitHub Actions runner
4751
- name: Checkout
4852
uses: actions/checkout@v4
4953
with:
50-
ref: ${{needs.tag_and_release.outputs.tag}}
54+
ref: ${{needs.tag_and_release.outputs.version}}
5155
fetch-depth: '0'
5256

5357
- name: Configure AWS Credentials
@@ -57,11 +61,7 @@ jobs:
5761
role-skip-session-tagging: true
5862
aws-region: ${{ vars.AWS_REGION }}
5963
mask-aws-account-id: true
60-
61-
- name: View AWS Role
62-
run: aws sts get-caller-identity
6364

64-
# Install the latest version of Terraform CLI and configure the Terraform CLI configuration file with a Terraform Cloud user API token
6565
- name: Setup Terraform
6666
uses: hashicorp/setup-terraform@v3
6767
with:
@@ -79,8 +79,7 @@ jobs:
7979
run: terraform workspace select ${{ secrets.AWS_WORKSPACE }}
8080
working-directory: ./infrastructure
8181
shell: bash
82-
83-
# Checks that all Terraform configuration files adhere to a canonical format
82+
8483
- name: Terraform Format
8584
run: terraform fmt -check
8685
working-directory: ./infrastructure
@@ -95,5 +94,3 @@ jobs:
9594
- name: Terraform Apply
9695
run: terraform apply -auto-approve -input=false tf.plan
9796
working-directory: ./infrastructure
98-
99-

0 commit comments

Comments
 (0)