CI #296
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: [master] | |
pull_request: | |
branches: [master] | |
schedule: | |
# ┌───────────── minute (0 - 59) | |
# │ ┌───────────── hour (0 - 23) | |
# │ │ ┌───────────── day of the month (1 - 31) | |
# │ │ │ ┌───────────── month (1 - 12 or JAN-DEC) | |
# │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT) | |
# │ │ │ │ │ | |
# * * * * * | |
- cron: "42 7 * * *" | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [20.x] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Setup Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Cache dependencies | |
uses: actions/cache@v3 | |
with: | |
path: | | |
**/node_modules | |
key: ${{ runner.os }}-${{ hashFiles('**/package.lock') }} | |
- name: Install dependencies | |
run: npm i | |
- name: Run type checking | |
run: npm run type | |
deploy: | |
runs-on: ubuntu-latest | |
needs: test | |
if: ${{ github.event_name == 'push' || github.event_name == 'schedule' }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- name: Cache dependencies | |
uses: actions/cache@v3 | |
with: | |
path: | | |
**/node_modules | |
key: ${{ runner.os }}-${{ hashFiles('**/package.lock') }} | |
- name: Install dependencies | |
run: npm i | |
- name: Cache Gatsby cache folder | |
uses: actions/cache@v3 | |
with: | |
path: .cache | |
key: gatsby-cache-folder | |
- name: Cache Gatsby public folder | |
uses: actions/cache@v3 | |
with: | |
path: public | |
key: gatsby-public-folder | |
- name: Build | |
run: npm run build | |
- name: Deploy | |
run: | | |
git config --global user.name $user_name | |
git config --global user.email $user_email | |
git remote set-url origin https://${github_token}@github.com/${repository} | |
npm run deploy | |
env: | |
user_name: "github-actions-bot" | |
user_email: "[email protected]" | |
github_token: ${{ secrets.ACTIONS_DEPLOY_ACCESS_TOKEN }} | |
repository: ${{ github.repository }} |