Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Param to disable build cache in github actions #18

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion .github/workflows/aws-live-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ on:
options:
- dev
- prod
cache:
description: 'Cache yarn and gatsby builds.'
type: choice
default: true
required: true
options:
- true
- false

# webhook trigger
repository_dispatch:
Expand Down Expand Up @@ -64,6 +72,7 @@ jobs:
aws_iam_role: ${{ secrets.IAM_ROLE }}
aws_bucket: ${{ matrix.AWS_BUCKET }}
aws_cloudfront_id: ${{ matrix.AWS_CLOUDFRONT_ID }}
build_with_cache: ${{ inputs.cache }}

- name: Webhook Build and Deploy
if: ${{ github.event.action == format('webhook-live-{0}', matrix.environment) }}
Expand All @@ -75,4 +84,5 @@ jobs:
strapi_token: ${{ secrets.STRAPI_TOKEN }}
aws_iam_role: ${{ secrets.IAM_ROLE }}
aws_bucket: ${{ matrix.AWS_BUCKET }}
aws_cloudfront_id: ${{ matrix.AWS_CLOUDFRONT_ID }}
aws_cloudfront_id: ${{ matrix.AWS_CLOUDFRONT_ID }}
build_with_cache: true
12 changes: 11 additions & 1 deletion .github/workflows/aws-preview-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ on:
options:
- dev
- prod
cache:
description: 'Cache yarn and gatsby builds.'
type: choice
default: true
required: true
options:
- true
- false

# webhook trigger
repository_dispatch:
Expand Down Expand Up @@ -64,6 +72,7 @@ jobs:
aws_iam_role: ${{ secrets.IAM_ROLE }}
aws_bucket: ${{ matrix.AWS_BUCKET }}
aws_cloudfront_id: ${{ matrix.AWS_CLOUDFRONT_ID }}
build_with_cache: ${{ inputs.cache }}

- name: Webhook Build and Deploy
if: ${{ github.event.action == format('webhook-preview-{0}', matrix.environment) }}
Expand All @@ -75,4 +84,5 @@ jobs:
strapi_token: ${{ secrets.STRAPI_TOKEN }}
aws_iam_role: ${{ secrets.IAM_ROLE }}
aws_bucket: ${{ matrix.AWS_BUCKET }}
aws_cloudfront_id: ${{ matrix.AWS_CLOUDFRONT_ID }}
aws_cloudfront_id: ${{ matrix.AWS_CLOUDFRONT_ID }}
build_with_cache: true
35 changes: 35 additions & 0 deletions .github/workflows/deploy/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ inputs:
aws_cloudfront_id:
required: true
type: string
build_with_cache:
required: false
type: bool
default: true


runs:
Expand All @@ -40,6 +44,37 @@ runs:
uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516
with:
node-version: 16

- name: Yarn cache
if: ${{ inputs.build_with_cache == true }}
uses: actions/cache@4723a57e26efda3a62cbde1812113b730952852d
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-

- name: Gatsby Cache Folder
if: ${{ inputs.build_with_cache == true }}
uses: actions/cache@4723a57e26efda3a62cbde1812113b730952852d
id: gatsby-cache-folder
with:
path: src/app/.cache
key: ${{ runner.os }}-cache-gatsby
restore-keys: |
${{ runner.os }}-cache-gatsby

- name: Gatsby Public Folder
if: ${{ inputs.build_with_cache == true }}
uses: actions/cache@4723a57e26efda3a62cbde1812113b730952852d
id: gatsby-public-folder
with:
path: src/app/public/
key: ${{ runner.os }}-public-gatsby
restore-keys: |
${{ runner.os }}-public-gatsby

- name: Build
id: build
shell: bash
Expand Down