.github/workflows/documentation.yaml
name: Publish documentation
on:
push:
branches:
- erxes-docs-blog
paths:
- 'docs/**'
- '.github/workflows/documentation.yaml'
pull_request:
branches:
- erxes-docs-blog
- develop
- master
paths:
- 'docs/**'
jobs:
checks:
if: github.event_name != 'push'
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12.19.x
# https://github.com/actions/cache/blob/master/examples.md#node---yarn
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Cache Node.js modules
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
uses: actions/cache@v1
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-docs-${{ hashFiles('docs/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-docs-${{ hashFiles('docs/yarn.lock') }}
${{ runner.os }}-yarn-docs-
${{ runner.os }}-yarn-
- name: Build
run: |
cd docs
yarn install --frozen-lockfile
yarn run build
gh-release:
if: github.event_name != 'pull_request'
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-node@v1
with:
node-version: 12.19.x
# https://github.com/actions/cache/blob/master/examples.md#node---yarn
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Cache Node.js modules
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
uses: actions/cache@v1
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-docs-${{ hashFiles('docs/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-docs-${{ hashFiles('docs/yarn.lock') }}
${{ runner.os }}-yarn-docs-
${{ runner.os }}-yarn-
- name: Add key to allow access to repository
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
run: |
mkdir -p ~/.ssh
ssh-keyscan github.com >> ~/.ssh/known_hosts
echo "${{ secrets.GH_PAGES_DEPLOY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
cat <<EOT >> ~/.ssh/config
Host github.com
HostName github.com
IdentityFile ~/.ssh/id_rsa
EOT
- name: Release to GitHub Pages
env:
USE_SSH: true
GIT_USER: git
run: |
cd docs
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
yarn install --frozen-lockfile
yarn deploy