Release v1.0.6 (#849) #56
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build docs | |
on: | |
# Build PRs | |
pull_request_target: | |
types: [ opened, synchronize, reopened ] | |
paths: | |
- 'docs/**' | |
- '.github/workflows/docs.yaml' | |
# On push event | |
push: | |
# Build only changes pushed into the `master` branch -- avoids double builds when you push in a branch which has a PR. | |
branches: | |
- master | |
- pipeline | |
paths: | |
- 'docs/**' | |
- '.github/workflows/docs.yaml' | |
workflow_dispatch: | |
permissions: | |
statuses: write | |
env: | |
REPOSITORY: ${{ github.repository }} | |
IS_FORK: ${{ github.event.pull_request.head.repo.full_name != vars.CURRENT_REPO || github.repository != vars.CURRENT_REPO }} | |
IS_PR: ${{ github.event_name == 'pull_request' }} | |
EVENT_NAME: ${{ toJSON(github.event_name) }} | |
# format: username:branch | |
PR_HEAD_LABEL: ${{ toJSON(github.event.pull_request.head.label) }} | |
PR_NUMBER: ${{ github.event.number }} | |
jobs: | |
docs: | |
environment: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != vars.CURRENT_REPO && 'external-collaborators' || '' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.pull_request.head.sha || github.sha }} | |
- name: Get current branch name | |
id: get_branch | |
run: | | |
if [ "${{ github.event_name }}" == "pull_request_target" ]; then | |
echo "branch_name=${{ github.event.pull_request.head.ref }}" >> $GITHUB_ENV | |
else | |
echo "branch_name=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV | |
fi | |
- name: Build docs | |
working-directory: docs | |
run: docker compose run build | |
- name: Publish | |
working-directory: docs | |
id: publish | |
env: | |
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} | |
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} | |
run: | | |
npm install -g netlify | |
is_master=${{ env.branch_name == 'master' }} | |
is_fork=${{ github.event.pull_request.head.repo.fork == true }} | |
[[ "$is_master" == "true" && "$is_fork" == "false" ]] && args=" --prod " | |
netlify deploy -d site/ $args | tee build.log | |
url=$(cat build.log | grep -iE "website(.+)url" | cut -f 2- -d":" | xargs) | |
echo "Url: $url" | |
echo "url=$url" >> $GITHUB_OUTPUT | |
- name: Post job result | |
uses: Sibz/github-status-action@v1 | |
if: always() | |
with: | |
authToken: ${{ secrets.GITHUB_TOKEN }} | |
context: Build docs / docs / netlify preview | |
repository: ${{ vars.CURRENT_REPO }} | |
state: ${{ job.status }} | |
sha: ${{ github.event.pull_request.head.sha || github.sha }} | |
target_url: ${{ steps.publish.outputs.url }} | |