Merge pull request #72 from springmeyer/dependabot/npm_and_yarn/handl… #16
This file contains hidden or 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: Build and Commit | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build | |
| run: npm run build | |
| - name: Check for changes | |
| id: check_changes | |
| run: | | |
| if git diff --exit-code --quiet; then | |
| echo "has_changes=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "has_changes=true" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Commit changes (main branch only) | |
| if: github.ref == 'refs/heads/main' && steps.check_changes.outputs.has_changes == 'true' | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add -A | |
| git commit -m "build: regenerate bundle" | |
| git push | |
| - name: Fail if changes detected (PR) | |
| if: github.event_name == 'pull_request' && steps.check_changes.outputs.has_changes == 'true' | |
| run: | | |
| echo "Bundle is out of sync. Please run 'npm run build' and commit the changes." | |
| exit 1 |