morgan1bathe is running Deploy Documentation CD #266
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: Deploy Documentation CD | |
run-name: ${{ github.actor }} is running Deploy Documentation CD | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
env: | |
BUILD_PATH: '.' # default value when not using subfolders | |
rid: ${{ github.run_id }}-${{ github.run_number }} | |
# Setting an environment variable with the value of a configuration variable | |
ALGOLIA_APP_ID: ${{ vars.ALGOLIA_APP_ID }} | |
ALGOLIA_INDEX_NAME: ${{ vars.ALGOLIA_INDEX_NAME }} | |
ALGOLIA_DOC_SEARCH: ${{ vars.ALGOLIA_DOC_SEARCH }} | |
jobs: | |
initialize: | |
name: Initialize | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Project | |
uses: actions/checkout@v3 | |
- name: Setup Node | |
uses: actions/setup-node@v3.7.0 | |
with: | |
node-version-file: '.nvmrc' | |
registry-url: 'https://registry.npmjs.org' | |
cache: 'yarn' | |
- name: Validate Dependencies | |
id: validate-dependencies | |
uses: actions/cache@v3 | |
with: | |
path: '**/node_modules' | |
key: node-modules-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} | |
- name: Install Dependencies | |
if: steps.validate-dependencies.outputs.cache-hit != 'true' | |
run: yarn | |
- name: Cache Dependencies | |
uses: actions/cache@v3 | |
if: steps.validate-dependencies.outputs.cache-hit != 'true' | |
with: | |
path: '**/node_modules' | |
key: node-modules-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
needs: initialize | |
steps: | |
- name: Checkout Project | |
uses: actions/checkout@v3 | |
- name: Setup Node | |
uses: actions/setup-node@v3.7.0 | |
with: | |
node-version-file: '.nvmrc' | |
registry-url: 'https://registry.npmjs.org' | |
cache: 'yarn' | |
- name: Uncache Dependencies | |
uses: actions/cache@v3 | |
with: | |
path: '**/node_modules' | |
key: node-modules-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} | |
- name: Synchronize Packages | |
run: yarn | |
- name: Build docs with astro (includes all dependencies + astro) | |
run: yarn build | |
working-directory: ${{ env.BUILD_PATH }} | |
- name: Cache Documentation | |
uses: actions/cache@v2 | |
with: | |
path: ${{ env.BUILD_PATH }}/packages/@momentum-design/docs/dist/ | |
key: docs-${{ runner.os }}-${{ env.rid }} | |
deploy: | |
name: Deploy | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Project | |
uses: actions/checkout@v2 | |
with: | |
ref: docs | |
- name: Clean Documentation | |
run: | | |
rm -rf ${{ env.BUILD_PATH }}/docs | |
- name: Uncache Documentation | |
uses: actions/cache@v2 | |
with: | |
path: ${{ env.BUILD_PATH }}/packages/@momentum-design/docs/dist/ | |
key: docs-${{ runner.os }}-${{ env.rid }} | |
- name: Process Cached Docs | |
run: cp -avr ${{ env.BUILD_PATH }}/packages/@momentum-design/docs/dist docs/ | |
- name: Generate GitHub Pages Config | |
run: | | |
touch docs/.nojekyll | |
echo "${{ env.rid }}" >> docs/run-id.hash | |
- name: Deploy Documentation | |
run: | | |
git config --local user.email "automation@momentum.design" | |
git config --local user.name "Momentum Design Automation" | |
git add ${{ env.BUILD_PATH }}/docs | |
FILE_COUNT=$(git status -s | wc -l | xargs) | |
if [[ $FILE_COUNT != '0' ]] | |
then | |
echo "Found $FILE_COUNT changed documentation files." | |
git commit -m "ci(docs): deploy documentation [skip ci] [skip release]" | |
git push origin docs --force | |
else | |
echo "Documentation files have not changed." | |
echo "Documentation will not be published." | |
fi |