Skip to content

Merge pull request #3224 from bright/cms/blog/software-engineer-with-… #5674

Merge pull request #3224 from bright/cms/blog/software-engineer-with-…

Merge pull request #3224 from bright/cms/blog/software-engineer-with-… #5674

Workflow file for this run

name: Publish website
on:
push:
branches:
- gatsby
- staging
workflow_dispatch:
inputs:
partytownEnabled:
description: 'Enable partytown'
required: true
default: 'false'
type: choice
options:
- 'true'
- 'false'
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18'
- name: Yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v3
name: Yarn cache
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-v29-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-v29-
- name: Restore Gatsby Cache
id: gatsby-cache-restore
uses: actions/cache/restore@v3
with:
path: |
public
.cache
key: ${{ runner.os }}-gatsby-build-v29-${{ github.ref_name }}
- run: yarn install
- run: yarn tsc --noEmit
- run: yarn run build
if: ${{ github.ref == 'refs/heads/gatsby' }}
env:
CI: true
GATSBY_ACTIVE_ENV: production
GATSBY_CPU_COUNT: 1
GATSBY_PARTYTOWN_ENABLED: ${{ inputs.partytownEnabled || 'false' }}
- run: yarn run deploy-s3
if: ${{ github.ref == 'refs/heads/gatsby' }}
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_CLOUDFRONT_DISTRIBUTION_ID: ${{ secrets.PRODUCTION_CLOUDFRONT_DISTRIBUTION_ID }}
GATSBY_ACTIVE_ENV: production
- run: yarn run invalidate-cf-cache
if: ${{ github.ref == 'refs/heads/gatsby' }}
env:
AWS_REGION: 'eu-central-1'
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_CLOUDFRONT_DISTRIBUTION_ID: ${{ secrets.PRODUCTION_CLOUDFRONT_DISTRIBUTION_ID }}
- run: yarn run build
if: ${{ github.ref == 'refs/heads/staging' }}
env:
CI: true
DEPLOY_S3_BUCKET_NAME: 'brightinventions-pl-website-content-staging'
GATSBY_ACTIVE_ENV: staging
GATSBY_SITE_URL: 'https://staging.brightinventions.pl/'
GATSBY_CPU_COUNT: 1
GATSBY_PARTYTOWN_ENABLED: ${{ inputs.partytownEnabled || 'false' }}
# Enable for debugging
# - name: Archive public folder
# uses: actions/upload-artifact@v3
# with:
# name: public
# path: public
- run: yarn run deploy-s3
if: ${{ github.ref == 'refs/heads/staging' }}
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_CLOUDFRONT_DISTRIBUTION_ID: ${{ secrets.STAGING_CLOUDFRONT_DISTRIBUTION_ID }}
GATSBY_SITE_URL: 'https://staging.brightinventions.pl/'
DEPLOY_S3_BUCKET_NAME: 'brightinventions-pl-website-content-staging'
GATSBY_ACTIVE_ENV: staging
- run: yarn run invalidate-cf-cache
if: ${{ github.ref == 'refs/heads/staging' }}
env:
AWS_REGION: 'eu-central-1'
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_CLOUDFRONT_DISTRIBUTION_ID: ${{ secrets.STAGING_CLOUDFRONT_DISTRIBUTION_ID }}
- name: Save Gatsby Cache
id: gatsby-cache-save
uses: actions/cache/save@v3
with:
path: |
public
.cache
key: ${{ runner.os }}-gatsby-build-v29-${{ github.ref_name }}