Skip to content

Pass asset cache between plan and apply actions #140

Pass asset cache between plan and apply actions

Pass asset cache between plan and apply actions #140

name: Run Terraform plan in staging
on:
pull_request:
branches: [ main ]
permissions:
contents: read
pull-requests: write
jobs:
terraform:
name: Terraform plan
runs-on: ubuntu-24.04
environment: staging
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: terraform validate
uses: dflook/terraform-validate@v1
with:
path: terraform
- name: terraform fmt
uses: dflook/terraform-fmt-check@v1
with:
path: terraform
- uses: ./.github/actions/setup-languages
- name: Asset cache
uses: actions/cache@v4
with:
key: staging-assets-build-${{ github.sha }}
restore-keys: staging-assets-deployed-
path: |
public/assets
app/assets/builds
app/javascript/generated
- name: Precompile assets and clean old versions
env:
RAILS_ENV: staging
SECRET_KEY_BASE_DUMMY: 1
run: ./bin/rake assets:precompile && ./bin/rake assets:clean
- name: terraform plan
uses: dflook/terraform-plan@v1
env:
TF_VAR_cf_user: ${{ secrets.CF_USERNAME }}
TF_VAR_cf_password: ${{ secrets.CF_PASSWORD }}
TF_VAR_rails_master_key: ${{ secrets.RAILS_MASTER_KEY }}
TERRAFORM_PRE_RUN: |
apt-get update
apt-get install -y zip
with:
path: terraform
var_file: terraform/staging.tfvars
add_github_comment: changes-only
backend_config: >
access_key=${{ secrets.TERRAFORM_STATE_ACCESS_KEY }}
secret_key=${{ secrets.TERRAFORM_STATE_SECRET_ACCESS_KEY }}
bucket=${{ secrets.TERRAFORM_STATE_BUCKET_NAME }}
key=terraform.tfstate.staging
- name: Save app zip
uses: actions/upload-artifact@v4
with:
name: app-src-plan
path: terraform/dist/src.zip
compression-level: 0
retention-days: 2