Skip to content

testing-workflow

testing-workflow #5

name: Build and Commit Dist Files On Merge
on:
pull_request:
types: [synchronize, opened, reopened]
jobs:
build:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '22'
- name: Install dependencies
run: yarn install
- name: Build project
run: yarn build
- name: Check for changes in dist
id: check_changes
run: |
if [ -n "$(git status --porcelain dist)" ]; then
echo "dist has changed"
echo "::set-output name=changed::true"
else
echo "dist is unchanged"
echo "::set-output name=changed::false"
fi
- name: Commit and push changes
if: steps.check_changes.outputs.changed == 'true'
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add dist
git commit --amend --no-edit
git push origin HEAD:${{ github.event.pull_request.head.ref }} --force
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}