-
Notifications
You must be signed in to change notification settings - Fork 766
98 lines (88 loc) · 3.78 KB
/
push.yml
File metadata and controls
98 lines (88 loc) · 3.78 KB
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
name: Push
on:
push:
branches: [master]
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write # Needed for git push operations
id-token: write # Required for OIDC trusted publishing
pull-requests: write # Needed to post release comments on PRs
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: '22.21.1'
registry-url: 'https://registry.npmjs.org'
- name: Enable Corepack
run: corepack enable
- uses: actions/cache@v4.3.0
id: yarn-cache
with:
path: .yarn/cache
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
run: yarn install --immutable
- name: Build packages
run: yarn build
- name: Generate docs
run: yarn docs:generate
- 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 committing tags
# - use OIDC trusted publishing for npm (no token required)
run: |
git config user.name github-actions
git config user.email github-actions@github.com
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/
touch CNAME
echo "visx.airbnb.tech" > CNAME
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