Merge pull request #2 from Guysnacho/automate-apply #1
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
on: | |
push: | |
branches: ["main"] | |
permissions: | |
pull-requests: write | |
name: 🌱 Apply, Build, Deploy | |
jobs: | |
TF-SignIn: | |
name: Terraform Sign-in 🗝️ | |
runs-on: ubuntu-latest | |
env: | |
tf_actions_working_dir: "terraform" | |
defaults: | |
run: | |
working-directory: ${{ env.tf_actions_working_dir }} | |
steps: | |
- name: Setup Terraform | |
uses: hashicorp/setup-terraform@v3 | |
with: | |
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }} | |
terraform_version: 1.9.2 | |
- run: terraform init | |
apply-infra: | |
name: 🎉 Deploy | |
runs-on: ubuntu-latest | |
needs: ["TF-SignIn"] | |
steps: | |
- name: Check Out | |
uses: actions/checkout@v4 | |
- name: 🏗️ Terraform Apply | |
run: | | |
cd terraform | |
terraform plan -no-color | |
- run: echo ${{ steps.plan.outputs.stdout }} | |
- run: echo ${{ steps.plan.outputs.stderr }} | |
- run: echo ${{ steps.plan.outputs.exitcode }} | |
web-deploy: | |
name: 🎉 Deploy | |
runs-on: ubuntu-latest | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
needs: ["apply-infra"] | |
defaults: | |
run: | |
working-directory: "web" | |
steps: | |
- name: Use Node.js | |
uses: actions/setup-node@v4 | |
with: | |
cache: "npm" | |
- name: 🔨 Build Project | |
run: | | |
npm install | |
npm run build | |
- name: 🚀 Upload Package | |
uses: reggionick/s3-deploy@v4 | |
with: | |
folder: out | |
bucket: ${{ secrets.S3_BUCKET }} | |
bucket-region: us-west-2 |