This repository has been archived on 2024-07-19. You can view files and clone it, but cannot push or open issues or pull requests.
infinite-wordle/.github/workflows/main.yml
Marc Cataford e501f01dfa
ci: parallelizes build tasks (#4)
* ci: parallelizes build tasks

* fix: duplicated attr

* ci: do not yarn if cache

* fix: artifact pull path

* chore: lint

* build: lint script

* ci: linting step

* ci: url extraction for PR comment
2022-01-25 23:21:59 -05:00

138 lines
3.9 KiB
YAML

name: Publish
on:
push:
branches: main
pull_request:
jobs:
setup:
runs-on: ubuntu-latest
name: Setup
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
- uses: actions/cache@v2
id: dep-cache
with:
path: node_modules
key: ${{ runner.os }}-${{ hashFiles('yarn.lock') }}
- name: Install
if: steps.dep-cache.outputs.cache-hit != 'true'
run: yarn
lint:
runs-on: ubuntu-latest
name: Lint
needs: setup
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
id: node-setup
with:
node-version: 16
- uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-${{ hashFiles('yarn.lock') }}
- name: Lint
run: yarn lint
build-frontend:
runs-on: ubuntu-latest
name: Build frontend
needs: setup
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
id: node-setup
with:
node-version: 16
- uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-${{ hashFiles('yarn.lock') }}
- name: Build
run: yarn build:frontend
- uses: actions/upload-artifact@v2
with:
name: frontend-dist
path: dist
build-dictionary:
runs-on: ubuntu-latest
name: Build dictionary
needs: setup
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
id: node-setup
with:
node-version: 16
- uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-${{ hashFiles('yarn.lock') }}
- name: Build dictionary
env:
DICTIONARY_TAG: rev_22-01-2022-22-04
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release download --repo mcataford/words ${{ env.DICTIONARY_TAG }}
yarn ts-node script/buildDictionary.ts
- uses: actions/upload-artifact@v2
with:
name: dictionary
path: puzzles.sqlite
publish:
runs-on: ubuntu-latest
name: Publish
needs: [lint, build-frontend, build-dictionary]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
id: node-setup
with:
node-version: 16
- uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-${{ hashFiles('yarn.lock') }}
- uses: actions/download-artifact@v2
with:
name: frontend-dist
path: dist
- uses: actions/download-artifact@v2
with:
name: dictionary
- name: Deploy preview
if: ${{ github.ref != 'refs/heads/main' }}
id: preview-deploy
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
run: |
yarn netlify deploy --json | jq '.deploy_url' -r > deploy_url.txt
echo "::set-output name=draft-url::$(cat deploy_url.txt)"
- name: Report
if: ${{ github.ref != 'refs/heads/main' }}
uses: actions/github-script@v2
env:
DRAFT_URL: ${{ steps.preview-deploy.outputs.draft-url }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `:eyes: Branch deployed at ${process.env.DRAFT_URL}`
})
- name: Deploy
if: ${{ github.ref == 'refs/heads/main' }}
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
run: |
yarn netlify deploy --prod