Skip to content

improve

improve #582

Workflow file for this run

name: Build package
on:
pull_request:
push:
branches: main
jobs:
build:
name: Build package
runs-on: ubuntu-latest
if: github.actor != 'dependabot[bot]'
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}
- uses: actions/setup-node@v4
with:
node-version: '22.x'
cache: 'npm'
- name: Lint, format & build code, generate docs
run: npm ci
- name: Commit & push changes
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add -A
git commit -m "Code maintenance: lint, format and build code, generate docs"
if [[ ${{ github.ref }} == "refs/heads/main" ]]; then
echo ${{ secrets.GITHUB_TOKEN }} | gh auth login --with-token
BRANCH_NAME="maintenance-$(date +'%Y%m%d%H%M%S')"
git checkout -b "$BRANCH_NAME"
git push origin "$BRANCH_NAME"
gh pr create --base main --head "$BRANCH_NAME" --title "Maintenance PR" --body "Automatic code maintenance: lint, format and build code, generate docs."
gh pr merge --auto --squash --delete-branch ${{ github.event.pull_request.html_url }}
else
git pull origin ${{ github.head_ref }} --rebase
git push origin HEAD:${{ github.head_ref }}
fi