Skip to content

[UIHC] Brand bar

[UIHC] Brand bar #3866

Workflow file for this run

name: Update documentation in GitHub Pages
# Triggers on pushes to branches and tags, as well a deleting a branch.
on:
push:
branches:
- "4.x"
tags:
- '*'
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
pull_request_target:
types: [opened, synchronize, reopened, ready_for_review]
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# If the PR is coming from a fork (pull_request_target), ensure it's opened by "dependabot[bot]".
# Otherwise, clone it normally.
if: |
! github.event.pull_request.draft &&
((github.event_name == 'pull_request_target' && github.actor == 'dependabot[bot]') ||
(github.event_name != 'pull_request_target' && github.actor != 'dependabot[bot]'))
env:
TARGET_BRANCH: gh-pages
MAIN_BRANCH: 4.x
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# https://github.com/actions/checkout#readme
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkout 🛎️
if: ${{ github.event_name != 'pull_request_target' }}
uses: actions/checkout@v3
- name: Checkout PR 🛎️
if: ${{ github.event_name == 'pull_request_target' }}
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Set variables for main
if: |
github.event_name == 'push' &&
github.ref == format('refs/heads/{0}', env.MAIN_BRANCH)
run: |
echo "branch=latest" >> $GITHUB_ENV
echo "target_dir=/" >> $GITHUB_ENV
- name: Set variables for branches
if: |
github.event_name == 'pull_request' ||
github.event_name == 'pull_request_target'
run: |
ref=${{ github.event.pull_request.head.ref }}
echo "branch=${ref//\//_}" >> $GITHUB_ENV
echo "target_dir=/branches/" >> $GITHUB_ENV
- name: Set variables for tags
if: ${{ startsWith(github.ref, 'refs/tags/') }}
run: |
ref=${{ github.ref }}
echo "branch=${ref#refs/*/}" >> $GITHUB_ENV
echo "target_dir=/docs/" >> $GITHUB_ENV
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: '18.x'
- name: Enable corepack
run: |
corepack enable
corepack prepare yarn@3.7.0 --activate
yarn set version 3.7.0
# Update NPM to 7 to fix https://github.com/actions/setup-node/issues/214.
# - run: npm install -g npm@7
# - run: npm -v
- run: yarn install --immutable
- run: BASE_URL=$target_dir$branch/ yarn production
# Check to make sure that docs built into www.
- run: ls -lah $GITHUB_WORKSPACE/www
# https://github.com/actions/checkout#readme
- name: Checkout docs
uses: actions/checkout@v2.3.1
with:
ref: gh-pages
path: gh-pages
# Debugging messages.
# - run: echo "${{ github.ref }}"
# - run: echo "${{ toJson(github) }}"
# - run: echo "${{ env.MAIN_BRANCH }}"
# - run: echo "Main check - ${{ github.ref == format('refs/heads/{0}', env.MAIN_BRANCH) }}"
# - run: echo "Branch check - ${{ contains(github.ref, 'refs/heads/') && github.ref != format('refs/heads/{0}', env.MAIN_BRANCH) }}"
# - run: echo "Tags check - ${{ startsWith(github.ref, 'refs/tags/') }}
# Only one of the following 3 steps should run.
# If tags:
# - Copy the build to the root of 'gh-pages'.
- name: Tag push preparations
if: startsWith(github.ref, 'refs/tags/')
run: |
cp -a $GITHUB_WORKSPACE/www/* $GITHUB_WORKSPACE/gh-pages
# If branch other than main:
# - Create the 'branches' directory if it doesn't exist.
# - Remove existing version of docs, if it exists.
# - Move build into versioned folder.
- name: Build branch docs
run: |
if [ ! -d "$GITHUB_WORKSPACE/gh-pages$target_dir" ]; then mkdir -p $GITHUB_WORKSPACE/gh-pages$target_dir ; fi
rm -rf $GITHUB_WORKSPACE/gh-pages$target_dir$branch
mv $GITHUB_WORKSPACE/www/ $GITHUB_WORKSPACE/gh-pages$target_dir$branch
# https://github.com/JamesIves/github-pages-deploy-action#readme
- name: Deploy docs 🚀
uses: JamesIves/github-pages-deploy-action@4.1.3
with:
branch: ${{ env.TARGET_BRANCH }} # The branch the action should deploy to.
folder: gh-pages