-
Notifications
You must be signed in to change notification settings - Fork 0
81 lines (73 loc) · 2.28 KB
/
yarn.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# 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
- name: eslint check
run: yarn lint
- name: TS check
run: yarn ts
- 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 }}