Skip to content

Commit e39a833

Browse files
committed
update pre-prod workflow
1 parent b72697e commit e39a833

File tree

1 file changed

+19
-22
lines changed

1 file changed

+19
-22
lines changed

.github/workflows/terraform-deploy-to-pre-prod-manual.yml

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,53 @@
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: "What branch or tagged version 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+
tag: ${{ steps.version.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
29-
id: versioning
33+
id: version
34+
if: ${{ github.event.inputs.branch_or_tag == 'main' }}
3035
uses: anothrNick/[email protected]
3136
env:
3237
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3338
WITH_V: false
3439
DEFAULT_BUMP: patch
35-
36-
- name: View outputs
37-
run: |
38-
echo Current tag: ${{steps.versioning.outputs.tag}}
39-
echo New tag: ${{steps.versioning.outputs.new_tag}}
4040

4141
terraform_process:
4242
runs-on: ubuntu-latest
4343
needs: ['tag_and_release']
4444
environment: pre-prod
45+
4546
steps:
46-
# Checkout the repository to the GitHub Actions runner
47+
- name: View outputs
48+
run: |
49+
echo Deploying branch or tagged version to pre-prod: ${{ needs.tag_and_release.outputs.tag }}
50+
4751
- name: Checkout
4852
uses: actions/checkout@v4
4953
with:
@@ -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)