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