Deploy application #2
Workflow file for this run
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 application | |
| on: | |
| push: | |
| branches-ignore: [ "main" ] | |
| workflow_dispatch: | |
| inputs: | |
| application: | |
| description: Application to deploy. | |
| required: true | |
| type: string | |
| environment: | |
| description: Environment to deploy to. | |
| default: development | |
| required: true | |
| type: environment | |
| permissions: | |
| contents: read | |
| jobs: | |
| deploy: | |
| name: Deploy ${{ inputs.application }} to ${{ inputs.environment }} | |
| runs-on: ubuntu-latest | |
| environment: ${{ inputs.environment }} | |
| env: | |
| AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| AWS_REGION: ${{ vars.AWS_REGION || 'us-east-1' }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws-region: us-east-1 | |
| - name: Setup OpenTofu | |
| uses: opentofu/setup-opentofu@v1 | |
| - name: Initialize OpenTofu | |
| working-directory: ./tofu/config/${{ inputs.environment }}/infra | |
| run: tofu init | |
| - name: Apply changes | |
| working-directory: ./tofu/config/${{ inputs.environment }}/infra | |
| run: tofu apply --target module.app\[\"${{ inputs.application }}\"] --auto-approve |