This repository has been archived by the owner on Oct 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
78 lines (75 loc) · 3.02 KB
/
docusaurus.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
name: Docusaurus-website-build
# Only trigger on:
# - master branch
# - PR or Pull Request event types
# - Docusaurus files: this file, docs/** and website/**
on:
push:
branches:
- master
paths:
- '.github/workflows/docusaurus.yml'
- 'docs/**'
- 'website/**'
pull_request:
paths:
- '.github/workflows/docusaurus.yml'
- 'docs/**'
- 'website/**'
env:
# Used by docusaurus publish-site command and comment-on-pr action
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO_NAME: ${{ github.event.repository.name }}
PATCH_SCRIPT_URL: https://raw.githubusercontent.com/finos/open-developer-platform/master/scripts/patch-docusaurus-config.sh
CONTRIBUTE_SCRIPT_URL: https://raw.githubusercontent.com/finos/open-developer-platform/master/scripts/build-contribute-page.sh
jobs:
website-build:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v1
- name: Install Node
uses: actions/setup-node@v1
- name: Install Website deps
run: npm install --prefix website
- name: Patch forked version
run: |
# Extract GitHub org/user and patch siteConfig.js only if not "finos"
REPO="${{ github.repository }}"
REPO_ORG=${REPO%"/"*}
if [ "$REPO_ORG" != "finos" ]
then echo "Repo organization is '$REPO_ORG', patching docusaurus configuration to work on a forked repo" ; curl ${{ env.PATCH_SCRIPT_URL }} | bash -s -- ${{ env.REPO_NAME }} $REPO_ORG
else echo "Skipping patching, as this is the FINOS Organization"
fi
- name: Build Website
run: |
curl ${{ env.CONTRIBUTE_SCRIPT_URL }} | bash -s
npm run build --prefix website
- name: Publish Website
run: |
# Extract GitHub org/user
REPO="${{ github.repository }}"
GIT_USERNAME=${REPO%/*}
# Set git user to finos-admin, if it's a push to a finos repo
if [ "$GIT_USERNAME" == "finos" ] && [ "${{github.event_name }}" == "push" ]
then GIT_USERNAME="finos-admin"
elif [ "$GIT_USERNAME" == "finos" ] && [ "${{github.event_name }}" == "pull_request" ]
then echo "Skipping publish, as this is a PR, not a Push event" ; exit 0
fi
# Configure git client
echo "Git repo - $REPO"
echo "Git user - $GIT_USERNAME"
echo "Event name - ${{github.event_name }}"
git config --global user.email "[email protected]"
git config --global user.name "$GIT_USERNAME"
echo "machine github.com login $GIT_USERNAME password $GITHUB_TOKEN" > ~/.netrc
# Run docusaurus-publish
GIT_USER=$GIT_USERNAME npm run publish-gh-pages --prefix website
- name: Create comment
if: github.event_name == 'pull_request'
uses: peter-evans/create-or-update-comment@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.number }}
body: Website [preview is available](https://${{ github.actor }}.github.io/${{ env.REPO_NAME }})
# reaction-type: '+1'