bad space #2
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: "Terraform Apply" | |
on: | |
push: | |
branches: | |
- main | |
env: | |
TF_CLOUD_ORGANIZATION: "zwell-test" | |
TF_API_TOKEN: "${{ secrets.TF_API_TOKEN }}" | |
AWS_ACCESS_KEY_ID: "${{ secrets.AWS_ACCESS_KEY_ID }}" | |
AWS_SECRET_ACCESS_KEY: "${{ secrets.AWS_SECRET_ACCESS_KEY }}" | |
BUILD_VERSION: "${{ github.sha }}" | |
TF_WORKSPACE: "static-hosting" | |
CONFIG_DIRECTORY: "./terraform/" | |
AWS_DEFAULT_REGION: "us-west-2" | |
jobs: | |
# builds and pushes image to ecr | |
terraform: | |
name: "Terraform Apply" | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
# Gets the most current config (tf.plan) for org + workspace combo | |
- name: Upload Configuration | |
uses: hashicorp/tfc-workflows-github/actions/upload-configuration@v1.0.0 | |
id: apply-upload | |
with: | |
workspace: ${{ env.TF_WORKSPACE }} | |
directory: ${{ env.CONFIG_DIRECTORY }} | |
# runs changes in terrafrom/ against current state to create a tf.plan | |
# tarraform plan | |
- name: Create Apply Run | |
uses: hashicorp/tfc-workflows-github/actions/create-run@v1.0.0 | |
id: apply-run | |
env: | |
TF_VAR_image_tag: "\"${{ env.BUILD_VERSION }}\"" | |
with: | |
workspace: ${{ env.TF_WORKSPACE }} | |
configuration_version: ${{ steps.apply-upload.outputs.configuration_version_id }} | |
# terraform apply the plan | |
- name: Apply | |
uses: hashicorp/tfc-workflows-github/actions/apply-run@v1.0.0 | |
if: fromJSON(steps.apply-run.outputs.payload).data.attributes.actions.IsConfirmable | |
id: apply | |
with: | |
run: ${{ steps.apply-run.outputs.run_id }} | |
comment: "Apply Run from GitHub Actions CI ${{ github.sha }}" | |
# Once uplaoding current build and not squashing, move before tf apply | |
# bucket needs to be there first... | |
s3: | |
name: "Push to s3" | |
needs: terraform | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-region: ${{ env.AWS_DEFAULT_REGION }} | |
- name: Upload assets to s3 | |
shell: bash | |
run: | | |
aws s3 cp ./index.html s3://dev.app.zwellhome.com/index.html | |
aws s3 cp ./404.html s3://dev.app.zwellhome.com/404.html | |