Updated template (#4) #6
This file contains 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 to AWS | |
on: | |
push: | |
paths: | |
- "cloud/**" | |
permissions: | |
id-token: write | |
contents: read | |
jobs: | |
changes: | |
runs-on: ubuntu-latest | |
outputs: | |
accounts: ${{ steps.changes.outputs.all_changed_files }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: tj-actions/changed-files@v41 | |
id: changes | |
with: | |
path: cloud | |
dir_names: "true" | |
dir_names_max_depth: 1 | |
json: true | |
quotepath: false | |
escape_json: false | |
RunApply: | |
runs-on: ubuntu-latest | |
needs: changes | |
strategy: | |
matrix: | |
account: ${{ fromJSON(needs.changes.outputs.accounts) }} | |
continue-on-error: true | |
container: blackbirdcloud/terraform-toolkit:0.0.8 | |
steps: | |
- name: Git clone the repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: change --global to --system | |
run: git config --global --add safe.directory /__w/YOURPROJECTNAME/YOURPROJECTNAME | |
- name: configure aws credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
role-to-assume: ${{ vars.AWS_IAM_ROLE }} | |
role-session-name: github-action | |
aws-region: ${{ vars.AWS_REGION }} | |
- name: apply | |
working-directory: ./cloud/${{ matrix.account }} | |
run: terragrunt run-all apply --terragrunt-fetch-dependency-output-from-state --terragrunt-non-interactive --terragrunt-ignore-external-dependencies --terragrunt-download-dir=../../.terragrunt-cache |