2020Deeya is running Deploy Documentation CD #23
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 | |
PUBLIC_ALGOLIA_APP_ID: ${{ secrets.PUBLIC_ALGOLIA_APP_ID }} | |
PUBLIC_ALGOLIA_INDEX_NAME: ${{ secrets.PUBLIC_ALGOLIA_INDEX_NAME }} | |
PUBLIC_ALGOLIA_DOC_SEARCH: ${{ secrets.PUBLIC_ALGOLIA_DOC_SEARCH }} | |
jobs: | |
initialize: | |
name: Initialize | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version-file: '.nvmrc' | |
registry-url: 'https://registry.npmjs.org' | |
cache: 'yarn' | |
- name: Validate Dependencies | |
id: validate-dependencies | |
uses: actions/cache@v4 | |
with: | |
path: '**/node_modules' | |
key: node-modules-${{ hashFiles('**/yarn.lock') }} | |
- name: Install Dependencies | |
run: yarn | |
- name: Cache Dependencies | |
uses: actions/cache@v4 | |
if: steps.validate-dependencies.outputs.cache-hit != 'true' | |
with: | |
path: '**/node_modules' | |
key: node-modules-${{ hashFiles('**/yarn.lock') }} | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
needs: initialize | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version-file: '.nvmrc' | |
registry-url: 'https://registry.npmjs.org' | |
cache: 'yarn' | |
- name: Uncache Dependencies | |
uses: actions/cache@v4 | |
with: | |
path: '**/node_modules' | |
key: node-modules-${{ hashFiles('**/yarn.lock') }} | |
- name: Synchronize Packages | |
run: yarn | |
- name: Build docs with astro (includes all dependencies + astro) | |
run: PUBLIC_ALGOLIA_APP_ID=${{ env.PUBLIC_ALGOLIA_APP_ID }} PUBLIC_ALGOLIA_INDEX_NAME=${{ env.PUBLIC_ALGOLIA_INDEX_NAME }} PUBLIC_ALGOLIA_DOC_SEARCH=${{ env.PUBLIC_ALGOLIA_DOC_SEARCH }} yarn build | |
working-directory: ${{ env.BUILD_PATH }} | |
- name: Cache Documentation | |
uses: actions/cache@v4 | |
with: | |
path: ${{ env.BUILD_PATH }}/packages/documentation/dist/ | |
key: docs-${{ env.rid }} | |
deploy: | |
name: Deploy | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: docs | |
- name: Clean Documentation | |
run: | | |
rm -rf ${{ env.BUILD_PATH }}/docs | |
- name: Uncache Documentation | |
uses: actions/cache@v4 | |
with: | |
path: ${{ env.BUILD_PATH }}/packages/documentation/dist/ | |
key: docs-${{ env.rid }} | |
- name: Process Cached Docs | |
run: cp -avr ${{ env.BUILD_PATH }}/packages/documentation/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 |