This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: "Deploy - Pre-prod" | |
| run-name: "${{ github.event.inputs.branch_or_tag }}" | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| branch_or_tag: | |
| description: "Branch or tag to deploy" | |
| required: true | |
| type: string | |
| default: main | |
| permissions: | |
| pull-requests: write | |
| id-token: write # This is required for requesting the JWT | |
| contents: read # This is required for actions/checkout | |
| jobs: | |
| tag_and_release: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.versioning.outputs.tag || github.event.inputs.branch_or_tag }} | |
| permissions: write-all | |
| steps: | |
| - name: Checkout main | |
| if: ${{ github.event.inputs.branch_or_tag == 'main' }} | |
| uses: actions/checkout@v5 | |
| with: | |
| ref: main | |
| fetch-depth: "0" | |
| - name: Bump version and push tag | |
| if: ${{ github.event.inputs.branch_or_tag == 'main' }} | |
| id: versioning | |
| uses: anothrNick/[email protected] | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| WITH_V: false | |
| DEFAULT_BUMP: patch | |
| - name: View outputs | |
| run: | | |
| echo Deploying branch or tagged version to pre-prod: ${{ steps.versioning.outputs.tag || github.event.inputs.branch_or_tag }} | |
| terraform_process: | |
| runs-on: ubuntu-latest | |
| needs: ["tag_and_release"] | |
| environment: pre-prod | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| with: | |
| ref: ${{needs.tag_and_release.outputs.version}} | |
| fetch-depth: "0" | |
| - name: Configure AWS Credentials | |
| uses: aws-actions/configure-aws-credentials@v5 | |
| with: | |
| role-to-assume: ${{ secrets.AWS_ASSUME_ROLE }} | |
| role-skip-session-tagging: true | |
| aws-region: ${{ vars.AWS_REGION }} | |
| mask-aws-account-id: true | |
| - name: Setup Terraform | |
| uses: hashicorp/setup-terraform@v3 | |
| with: | |
| terraform_version: 1.11.4 | |
| terraform_wrapper: false | |
| - name: Terraform Init | |
| id: init | |
| run: terraform init -backend-config=backend-pre-prod.conf | |
| working-directory: ./infrastructure | |
| shell: bash | |
| - name: Terraform Set Workspace | |
| id: workspace | |
| run: terraform workspace select ${{ secrets.AWS_WORKSPACE }} | |
| working-directory: ./infrastructure | |
| shell: bash | |
| - name: Terraform Format | |
| run: terraform fmt -check | |
| working-directory: ./infrastructure | |
| - name: Terraform Plan | |
| id: plan | |
| run: | | |
| terraform plan -input=false -no-color -var-file="${{vars.TF_VARS_FILE}}" -out tf.plan | |
| working-directory: ./infrastructure | |
| shell: bash | |
| - name: Terraform Apply | |
| run: terraform apply -auto-approve -input=false tf.plan | |
| working-directory: ./infrastructure |