Update workflow: Auto-commit dist files on releases #1
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 Package Action | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| release: | |
| types: [ published ] | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Run tests | |
| run: npm test | |
| - name: Build and package action | |
| run: npm run package | |
| - name: Check if dist/index.js exists | |
| run: | | |
| if [ ! -f "dist/index.js" ]; then | |
| echo "Error: dist/index.js was not created" | |
| exit 1 | |
| fi | |
| echo "✅ dist/index.js created successfully" | |
| ls -la dist/ | |
| - name: Upload build artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: action-dist | |
| path: dist/ | |
| retention-days: 30 | |
| - name: Commit dist files (on release) | |
| if: github.event_name == 'release' | |
| run: | | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "GitHub Action" | |
| git add dist/ | |
| git diff --staged --quiet || git commit -m "Build: Update dist files for release ${{ github.event.release.tag_name }}" | |
| git push |