Skip to content

dev-deploy

dev-deploy #2513

Workflow file for this run

name: Build and deploy to preview
on:
repository_dispatch:
types: dev-deploy
push:
branches:
- preview
workflow_dispatch:
env:
NODE_OPTIONS: '--max_old_space_size=8192'
jobs:
build:
runs-on: 'ubuntu-latest'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
steps:
- uses: actions/checkout@v3
with:
ref: 'preview'
- name: update submodules
run: |
git submodule init
git submodule update --remote
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- name: Caching yarn
uses: actions/cache@v3
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-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
${{ runner.os }}-yarn-
# - name: Caching Gatsby
# id: gatsby-cache-build
# uses: actions/cache@v2
# with:
# path: |
# public
# .cache
# key: ${{ runner.os }}-gatsby-build-preview-${{ github.run_id }}
# restore-keys: |
# ${{ runner.os }}-gatsby-build-preview
- name: Installing dependencies
run: yarn install
- name: Building Gatsby site
run: yarn build
env:
MSERVICE_URL: ${{ secrets.MSERVICE_URL }}
IS_PREVIEW: preview
# env:
# GATSBY_EXPERIMENTAL_PAGE_BUILD_ON_DATA_CHANGES: true
# CI: true
- name: Sync files
run: |
echo ${{ secrets.RSYNC_PASSWORD }} > rsync.pass
sudo chmod 600 rsync.pass
sudo chown root rsync.pass
sudo rsync --password-file=rsync.pass -rDvpzc --delete public/ rsync://${{secrets.PREVIEW_SITE}}