-
Notifications
You must be signed in to change notification settings - Fork 113
112 lines (92 loc) · 3.04 KB
/
build.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
101
102
103
104
105
106
107
108
109
110
111
112
name: Build and Deploy
on:
pull_request:
push:
branches:
- main
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
pull-requests: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-node@v4
with:
node-version: '18.17.1'
cache: 'yarn'
- name: Install Dependencies 📦
run: |
yarn install --immutable
yarn manypkg check
- name: Build Packages 🔨
run: yarn build:packages
- name: Build Website 🔨
run: yarn build:website
env:
DEPLOY_PRIME_URL: https://rohit-gohri.github.io/
DEPLOY_BASE_URL: /redocusaurus/
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: website/build
if: ${{ github.event_name == 'push' }}
deploy-pages:
if: ${{ github.event_name == 'push' }}
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build-and-deploy
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
publish-test:
runs-on: ubuntu-latest
if: ${{ github.event_name != 'push' && github.head_ref != 'changeset-release/main' }}
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '18.17.1'
cache: 'yarn'
registry-url: 'https://registry.npmjs.org'
- name: Install Dependencies 📦
run: yarn install --immutable
- name: Build Packages 🔨
run: yarn build:packages
- name: Generate snapshot versions
run: yarn changeset version --snapshot test
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Get version
run: |
yarn workspace redocusaurus exec "sh $PWD/scripts/version.sh" >> $GITHUB_ENV
- name: Publish
run: yarn changeset publish --tag test
if: ${{ env.publish == 'yes' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Add comment
if: ${{ env.publish == 'yes' }}
uses: thollander/actions-comment-pull-request@v2
with:
message: |
This pull request is automatically built and it is testable by installing [redocusaurus@v${{ env.package_version }}](https://www.npmjs.com/package/redocusaurus/v/${{ env.package_version }}).
For commit [${{ github.sha }}](https://github.com/rohit-gohri/redocusaurus/commit/${{ github.sha }}).
comment_tag: 'automatically-publish'
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}