Skip to content

Commit

Permalink
Pass asset cache between plan and apply actions
Browse files Browse the repository at this point in the history
  • Loading branch information
rahearn committed Jan 3, 2025
1 parent 42ae3a5 commit fd835c2
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 18 deletions.
34 changes: 27 additions & 7 deletions .github/workflows/deploy-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
# - uses: ./.github/actions/setup-languages

# - name: Restore asset cache
# uses: actions/cache/restore@v4
# with:
# key: cache-staging-assets
# path: public/assets
- uses: ./.github/actions/setup-languages
- name: Restore asset cache
uses: actions/cache/restore@v4
with:
key: staging-assets-build-${{ github.sha }}
fail-on-cache-miss: true
path: |
public/assets
app/assets/builds
app/javascript/generated
- name: Terraform apply
uses: dflook/terraform-apply@v1
Expand Down Expand Up @@ -62,3 +65,20 @@ jobs:
cf_org: gsa-tts-devtools-prototyping
cf_space: capoc-stage-egress
cf_command: bind-security-group public_networks_egress $INPUT_CF_ORG --space $INPUT_CF_SPACE

- name: Save deployed assets cache
uses: actions/cache/save@v4
with:
key: staging-assets-deployed-${{ github.sha }}
path: |
public/assets
app/assets/builds
app/javascript/generated
- name: Save app zip
uses: actions/upload-artifact@v4
with:
name: app-src-apply
path: terraform/dist/src.zip
compression-level: 0
retention-days: 2
35 changes: 24 additions & 11 deletions .github/workflows/terraform-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,21 @@ jobs:
with:
path: terraform

# - uses: ./.github/actions/setup-languages
# - name: Use asset cache
# uses: actions/cache@v4
# with:
# key: cache-staging-assets
# path: public/assets
# - 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
- 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
Expand All @@ -53,8 +57,17 @@ jobs:
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

0 comments on commit fd835c2

Please sign in to comment.