Add changes to dist and docs #637
Workflow file for this run
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
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions | |
name: Last commit | |
on: [push] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [16.x] | |
steps: | |
- uses: actions/checkout@master | |
with: | |
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token | |
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo | |
- name: Build files with Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- run: npm ci | |
- run: npm run build | |
- name: Add file(s) for commit | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
git add -f dist/floorplan.js | |
git add -f dist/floorplan-examples.js | |
git add -f docs/_docs/floorplan/floorplan-examples.js | |
- name: Commit changes | |
id: can_commit | |
run: |- | |
commit_result=$(git commit -m "Add changes to dist and docs" -a | tr -d '\n' || true) | |
echo "::set-output name=commit_result::$commit_result" | |
- name: Nothing to commit | |
if: contains(steps.can_commit.outputs.commit_result, 'nothing to commit') | |
run: echo "No changes found (for both main code and docs). Skipping push." | |
- name: Dump GitHub context | |
run: echo $JSON | |
env: | |
JSON: ${{ toJSON(github) }} | |
- name: Push changes to target branch | |
if: (contains(steps.can_commit.outputs.commit_result, 'nothing to commit') == false) | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: ${{ github.ref_name }} |