Update dependency @actions/core to v1.10.1 #54
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: rebuild dist/ if needed | |
on: | |
pull_request: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: ${{github.head_ref}} | |
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 | |
- uses: actions/[email protected] | |
with: | |
cache: 'npm' | |
node-version-file: '.nvmrc' | |
- run: npm install | |
- name: build dist/ | |
run: npm run build | |
- run: | | |
STATUS=$(git diff --quiet && echo clean || echo modified) | |
echo "status=$(echo $STATUS)" >> $GITHUB_OUTPUT | |
id: gitStatus | |
- run: | | |
echo ${{ steps.gitStatus.outputs.status }} | |
echo ${{ contains(steps.gitStatus.outputs.status, 'modified') }} | |
- name: Commit dist/ files | |
if: contains(steps.gitStatus.outputs.status, 'modified') | |
run: | | |
set -x | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
git commit -m "rebuild dist/" -a | |
- id: auth | |
if: contains(steps.gitStatus.outputs.status, 'modified') | |
uses: jnwng/github-app-installation-token-action@v2 | |
with: | |
appId: ${{ secrets.COMMIT_BUILD_TO_PR_APP_ID }} | |
installationId: ${{ secrets.COMMIT_BUILD_TO_PR_INSTALLATION_ID }} | |
privateKey: ${{ secrets.COMMIT_BUILD_TO_PR_PRIVATE_KEY }} | |
- name: Push changes | |
if: contains(steps.gitStatus.outputs.status, 'modified') | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ steps.auth.outputs.token }} | |
branch: ${{github.head_ref}} |