forked from airbnb/visx
-
Notifications
You must be signed in to change notification settings - Fork 0
101 lines (91 loc) · 4.2 KB
/
push.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
name: Push
on:
push:
branches: [master]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2 # checkout visx + this commit
with:
# pulls all commits (needed for lerna to correctly release only changed packages)
fetch-depth: '0'
- uses: actions/setup-node@v2
with:
node-version: '12'
registry-url: 'https://registry.npmjs.org'
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v1
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: 📡 Install dependencies
run: yarn install --frozen-lockfile --ignore-engines
- name: 🛠 Build packages
run: yarn build
- name: 📐 Commit package sizes
if: github.repository_owner == 'airbnb'
# note: `git diff-index --quiet HEAD`
# has exit code 0 if there are changes vs HEAD, else nothing to commit
run: |
yarn build:sizes
git config user.name github-actions
git config user.email github-actions@github.com
git add .
git diff-index --quiet HEAD || git commit -m "build(${GITHUB_SHA}): auto-commit package sizes"
git push
- name: 🚀 Release
if: github.repository_owner == 'airbnb'
# the following configurations are needed for lerna to
# - have git credentials for commiting tags
# - have correct npm credentials for publishing (yarn does not work)
run: |
git config user.name github-actions
git config user.email github-actions@github.com
yarn logout
npm config set '//registry.npmjs.org/:_authToken=${{ secrets.NPM_AUTH_TOKEN }}'
yarn build:release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: 🎨 Build and deploy gallery
# below we
# - setup git credentials provided via actions/checkout@v2
# - initialize gh-pages-branch as an orphan branch so we don't build history
# - checkout the current commit and create gh-pages-root-dir/ as a new worktree
# - outside that directory HEAD is detached at $GITHUB_SHA
# - within that directory we are on the gh-pages-branch we just initialized
# *worktree initialization should be in a root dir, otherwise the worktree inherits nested directories
# - build the static next.js site and copy the output into gh-pages-root-dir/
# - we can't output directly into gh-pages-root-dir/ because next wipes the folder including .git
# - commit the demo site within gh-pages-root-dir/ onto the gh-pages-branch
# - push gh-pages-branch to visx as gh-pages. we overwrite history every time so it must be forced
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git checkout --orphan gh-pages-branch
git reset --hard
touch .nojekyll
git add .nojekyll
git commit -m "bot(${GITHUB_SHA}): initialize gh-pages branch"
git checkout "$GITHUB_SHA"
git worktree add gh-pages-root-dir gh-pages-branch
cd ./packages/visx-demo/
yarn build
mv -v out/* ../../gh-pages-root-dir/
cd ../../gh-pages-root-dir/
git add .
git commit -m "bot(${GITHUB_SHA}): build gh-pages"
git push -f "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$GITHUB_REPOSITORY.git" HEAD:gh-pages
- name: 🦛 Run happo
# not running happo on push results in stale base shas in pull_request
run: yarn run happo-ci-github-actions
working-directory: './packages/visx-demo/'
env:
HAPPO_API_KEY: ${{ secrets.HAPPO_API_KEY }}
HAPPO_API_SECRET: ${{ secrets.HAPPO_API_SECRET }}
HAPPO_COMMAND: '../../node_modules/happo.io/build/cli.js'