name: Format on: push: paths: - 'lua/**.lua' - '**.md' branches: [main, dev] jobs: format: runs-on: ubuntu-latest permissions: contents: write pull-requests: write env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - uses: actions/checkout@v3 - name: Setup git run: | git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" git config --local user.name "github-actions[bot]" printf 'STYLE_BRANCH=bot/style/%s\n' ${GITHUB_REF#refs/heads/} >> $GITHUB_ENV - name: Checkout to style branch run: git checkout -b ${STYLE_BRANCH} - uses: JohnnyMorganz/stylua-action@v1 with: token: ${{ secrets.GITHUB_TOKEN }} args: --check lua - uses: actions/setup-node@v3 - name: Apply prettier run: | npm install -g prettier prettier --write **/*.md - name: Create PR run: | if ! [[ -z $(git status -s) ]]; then git add -u git commit -m "chore: format" git push --force https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY} ${STYLE_BRANCH} gh pr create --fill --base ${GITHUB_REF#refs/heads/} --head ${STYLE_BRANCH} || true fi