@@ -2,64 +2,77 @@ name: Deploy
22
33on :
44 push :
5- branches : [ main, master ]
5+ branches :
6+ - main
7+ # branches that match deploy-* will deploy as well
8+ - deploy-*
69 workflow_dispatch :
710
811env :
912 AWS_ACCESS_KEY_ID : ${{ secrets.AWS_ACCESS_KEY_ID }}
1013 AWS_SECRET_ACCESS_KEY : ${{ secrets.AWS_SECRET_ACCESS_KEY }}
1114 AWS_DEFAULT_REGION : us-east-1
12- TG_WORKING_DIR : terragrunt/live/website
15+ working_dir : terragrunt/live/website
1316
1417concurrency :
1518 group : ${{ github.workflow }}
1619
1720jobs :
18- build :
21+ deploy :
1922 runs-on : ubuntu-latest
2023
2124 steps :
2225 - uses : actions/checkout@v5
2326
24- - name : Set up Ruby
25- uses : ruby/setup-ruby@v1
27+ - name : Update Terraform State and Providers
28+ uses : gruntwork-io/terragrunt-action@v3
29+ # env:
30+ # TF_LOG: DEBUG
31+ # INPUT_PRE_EXEC_1: |
32+ # echo "Current directory: $(pwd)"
33+ # ls -la
34+ # git status
2635 with :
27- bundler-cache : true
36+ tg_dir : ${{ env.working_dir }}
37+ tg_command : init --upgrade
2838
29- - name : Setup Terraform
30- uses : hashicorp/setup-terraform @v3.1.2
39+ - name : Terragrunt Plan
40+ uses : gruntwork-io/terragrunt-action @v3
3141 with :
32- terraform_version : 1.13.4
33- terraform_wrapper : true
42+ tg_dir : ${{ env.working_dir }}
43+ tg_command : plan
3444
35- - name : Setup Terragrunt
36- uses : autero1/action- terragrunt@v3.0.2
45+ - name : Terragrunt Apply
46+ uses : gruntwork-io/ terragrunt-action @v3
3747 with :
38- terragrunt-version : 0.86.0
39- token : ${{ secrets.GITHUB_TOKEN }}
48+ tg_dir : ${{ env.working_dir }}
49+ tg_command : apply
4050
41- - name : Update Terraform State and Providers
42- run : |
43- cd "$TG_WORKING_DIR"
44- terragrunt init --upgrade
51+ # - name: Terragrunt Output
52+ # uses: gruntwork-io/terragrunt-action@v3
53+ # env:
54+ # TG_TF_FORWARD_STDOUT: 1
55+ # TG_NO_COLOR: 1
56+ # with:
57+ # tg_dir: ${{ env.working_dir }}
58+ # tg_command: output
4559
46- - name : Terragrunt Plan
47- run : terragrunt plan --chdir $TG_WORKING_DIR
48-
49- - name : Terragrunt Apply
50- run : terragrunt apply -auto-approve --chdir $TG_WORKING_DIR
51-
52- - name : Terragrunt Output
53- id : terraform
60+ - name : Read Values
61+ id : terragrunt_output
5462 run : |
55- printf "distribution_id=%s\n" $(terragrunt output --chdir $TG_WORKING_DIR distribution_id) >> "$GITHUB_OUTPUT"
56- printf "bucket_name=%s\n" $(terragrunt output --chdir $TG_WORKING_DIR bucket_name) >> "$GITHUB_OUTPUT"
63+ cd terragrunt/live/website
64+ printf "distribution_id=%s\n" $(terragrunt output distribution_id) >> "$GITHUB_OUTPUT"
65+ printf "bucket_name=%s\n" $(terragrunt output bucket_name) >> "$GITHUB_OUTPUT"
5766
5867 - name : Build Jekyll project
59- run : bundle exec rake build
68+ run : |
69+ bundle install
70+ bundle exec rake build
71+
72+ # TODO: fail workflow if bucket name or distribution_id is not found
6073
6174 - name : Copy output to S3
62- run : aws s3 sync ./_site/ s3://${{ steps.terraform .outputs.bucket_name }} --acl public-read --delete --cache-control max-age=604800
75+ run : aws s3 sync ./_site/ s3://${{ steps.terragrunt_output .outputs.bucket_name }} --acl public-read --delete --cache-control max-age=604800
6376
6477 - name : Invalidate Cloudfront
65- run : aws cloudfront create-invalidation --distribution-id ${{ steps.terraform .outputs.distribution_id }} --paths "/*"
78+ run : aws cloudfront create-invalidation --distribution-id ${{ steps.terragrunt_output .outputs.distribution_id }} --paths "/*"
0 commit comments