Fix workflow for autogenerating docs (#592)

* Use grep -c flag in check for changes step to fix case when more than 1 website file was modified
This commit is contained in:
Szymon Fugas 2021-07-07 13:18:18 +02:00 committed by GitHub
parent 63370a55cc
commit b407e51bba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 13 deletions

View File

@ -23,18 +23,15 @@ jobs:
submodules: recursive # Fetch the Docsy theme
fetch-depth: 0
# Checks out a copy of your repository on the ubuntu-latest machine
# Checks if the previous commit introduced any changes to website files
- name: Check for changes
run: |
if git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep -E "^website*"; then
git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep -E "^website*"
echo "IS_CHANGED=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep -E "^website*")" >> $GITHUB_ENV
else
echo "IS_CHANGED=empty" >> $GITHUB_ENV
fi
IS_CHANGED=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep -Ec "^website*" || :)
[[ $IS_CHANGED -gt 0 ]] && echo "IS_CHANGED=true" >> $GITHUB_ENV || echo "IS_CHANGED=false" >> $GITHUB_ENV
# Sets up the appropriate version of Hugo
- name: Setup Hugo
if: env.IS_CHANGED != 'empty'
if: env.IS_CHANGED == 'true'
uses: peaceiris/actions-hugo@v2
with:
hugo-version: '0.62.2'
@ -42,14 +39,14 @@ jobs:
# Sets up node - required by Hugo
- name: Setup Node
if: env.IS_CHANGED != 'empty'
if: env.IS_CHANGED == 'true'
uses: actions/setup-node@v1
with:
node-version: '12.x'
# Installs dependencies required by docsy theme
- name: Install docsy dependencies
if: env.IS_CHANGED != 'empty'
if: env.IS_CHANGED == 'true'
run: |
cd website
npm install
@ -57,17 +54,18 @@ jobs:
sudo npm install -D --save autoprefixer
sudo npm install -D --save postcss-cli
cd ../
# Runs makefile goal - checks changes to /website folder and generates docs
- name: Run Makefile goal
if: env.IS_CHANGED != 'empty'
if: env.IS_CHANGED == 'true'
env:
DEFAULT_BRANCH: master
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: make generate-docs
# Create push request with generated docs
# Creates pull request with generated docs
- name: Create Pull Request
if: env.IS_CHANGED != 'empty'
if: env.IS_CHANGED == 'true'
uses: peter-evans/create-pull-request@v3
with:
commit-message: Auto-updated docs