Run prettier check in CI #79
Workflow file for this run
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
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions | |
name: Yarn CI & CD | |
on: | |
# runs on all pull requests against main | |
pull_request: | |
branches: [main] | |
workflow_call: | |
inputs: | |
release: | |
required: false | |
type: boolean | |
jobs: | |
build: | |
runs-on: ubuntu-20.04 | |
strategy: | |
matrix: | |
node-version: [16.x] | |
outputs: | |
sha_short: ${{ steps.vars.outputs.sha_short }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: "npm" | |
- name: Install production-level yarn dependencies | |
uses: Borales/[email protected] | |
with: | |
cmd: install --frozen-lockfile | |
- name: Prettier check | |
run: yarn "prettier:check" | |
- name: Build output for prod | |
uses: Borales/[email protected] | |
with: | |
cmd: build | |
- name: tar files together before artifact creation | |
run: tar -cvf build.tar build/ | |
- name: Upload build.zip artifact for release | |
uses: actions/upload-artifact@v3 | |
with: | |
name: build | |
path: build.tar | |
- name: Set variables for tag generation | |
id: vars | |
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" | |
# CD-specific job | |
release: | |
if: ${{ inputs.release }} | |
needs: build | |
runs-on: ubuntu-20.04 | |
strategy: | |
matrix: | |
node-version: [16.x] | |
steps: | |
- name: Download artifact from build | |
uses: actions/download-artifact@v3 | |
with: | |
name: build | |
- name: Generate release | |
uses: ncipollo/release-action@v1 | |
with: | |
allowUpdates: false | |
artifactErrorsFailBuild: true | |
artifacts: "build.tar" | |
# don't use {{ github.sha }} here since that's the full SHA | |
tag: 1.0.0-${{ needs.build.outputs.sha_short }} | |
token: ${{ secrets.GITHUB_TOKEN }} |