Skip to content
This repository was archived by the owner on Mar 8, 2024. It is now read-only.

Commit d61f8f4

Browse files
authored
Deploy PRs to github pages (#121)
1 parent 9bcc5cd commit d61f8f4

2 files changed

Lines changed: 75 additions & 0 deletions

File tree

.github/workflows/docusaurus.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: 'Docusaurus build only on PR'
2+
3+
on:
4+
pull_request:
5+
types: [opened, edited, synchronize]
6+
7+
jobs:
8+
build:
9+
name: Build Docusaurus Site
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
- name: Npm Setup
14+
uses: actions/setup-node@v1
15+
with:
16+
node-version: 12.x
17+
- name: Npm Install
18+
run: |
19+
npm i
20+
- name: Lint
21+
run: npm run lint
22+
- name: PR Branch Name
23+
uses: mdecoleman/pr-branch-name@1.0.0
24+
id: branchname
25+
with:
26+
repo-token: ${{ secrets.GITHUB_TOKEN }}
27+
- name: GitHub Environment Variables Action
28+
uses: FranzDiebold/github-env-vars-action@v1.2.0
29+
- name: Get PR commit trigger SHA
30+
uses: bhowell2/github-substring-action@v1.0.0
31+
id: prsha
32+
with:
33+
value: ${{ github.event.pull_request.head.sha }}
34+
length_from_start: 6
35+
- name: Get short SHA6
36+
id: slug
37+
env:
38+
PRSHA: ${{ steps.prsha.outputs.substring }}
39+
run: echo "::set-output name=sha6::$(echo ${PRSHA} | cut -c1-6)"
40+
- name: Get PR commit trigger SHA
41+
uses: bhowell2/github-substring-action@v1.0.0
42+
id: prsha7
43+
with:
44+
value: ${{ github.event.pull_request.head.sha }}
45+
length_from_start: 7
46+
- name: Get short SHA7
47+
id: slug7
48+
env:
49+
PRSHA: ${{ steps.prsha7.outputs.substring }}
50+
run: echo "::set-output name=sha7::$(echo ${PRSHA} | cut -c1-7)"
51+
- name: Modify Docusaurus prefix in docusaurus.config.js
52+
env:
53+
SHA: ${{ steps.slug.outputs.sha6 }}
54+
BRANCH: ${{ steps.branchname.outputs.branch }}
55+
SLUG: ${{ env.GITHUB_REPOSITORY_NAME }}
56+
run: |
57+
sed -i "s@baseUrl: '/'@baseUrl: '/${SLUG}/review-apps/${BRANCH}/${SHA}/'@g" docusaurus.config.js
58+
- name: Build and deploy to gh-pages
59+
uses: sauloxd/review-apps@v1.3.2
60+
with:
61+
build-cmd: 'npx docusaurus build'
62+
branch: 'gh-pages'
63+
dist: 'build'
64+
slug: 'review-apps'
65+
- name: Comment URL on PR
66+
uses: unsplash/comment-on-pr@master
67+
env:
68+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
69+
SHA: ${{ github.event.pull_request.head.sha }}
70+
with:
71+
msg: 'https://${{env.GITHUB_REPOSITORY_OWNER_SLUG}}.github.io/${{env.GITHUB_REPOSITORY_NAME}}/review-apps/${{steps.branchname.outputs.branch}}/${{steps.slug.outputs.sha6}}?version=${{steps.slug7.outputs.sha7}}'
72+
check_for_duplicate_msg: false

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
"name": "payid-documentation",
33
"version": "1.0.0",
44
"private": true,
5+
"engines": {
6+
"node": ">= 12"
7+
},
58
"scripts": {
69
"start": "docusaurus start",
710
"prebuild": "prettier --check '**/*.md'",

0 commit comments

Comments
 (0)