mirror of
https://github.com/tiennm99/is-a-dev.git
synced 2026-05-17 16:59:47 +00:00
63 lines
2.0 KiB
YAML
63 lines
2.0 KiB
YAML
name: Prettier
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
paths:
|
|
- "domains/*"
|
|
- ".github/workflows/prettier.yml"
|
|
|
|
jobs:
|
|
format:
|
|
name: Format
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20.x
|
|
|
|
- name: Run Prettier
|
|
run: npx -y prettier ./domains -w --tab-width 2 --print-width 120
|
|
|
|
- name: Create branch
|
|
run: |
|
|
BRANCH_NAME="prettier-$(date +%s)"
|
|
echo "Generated branch: $BRANCH_NAME"
|
|
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
|
|
git checkout -b "$BRANCH_NAME"
|
|
|
|
- name: Commit
|
|
run: |
|
|
git config --local user.email "bot@is-a.dev"
|
|
git config --local user.name "is-a-dev-bot"
|
|
git add .
|
|
git commit -m "chore: apply formatting"
|
|
|
|
- name: Push
|
|
env:
|
|
API_TOKEN_GITHUB: ${{ secrets.BOT }}
|
|
run: |
|
|
git push -u origin "$BRANCH_NAME"
|
|
|
|
- name: Create pull request
|
|
id: create_pr
|
|
uses: peter-evans/create-pull-request@v7
|
|
with:
|
|
token: ${{ secrets.BOT }}
|
|
author: is-a-dev-bot <bot@is-a.dev>
|
|
branch: "$BRANCH_NAME"
|
|
base: main
|
|
title: "$BRANCH_NAME"
|
|
body: "Generated from https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}."
|
|
|
|
- name: Merge pull request
|
|
if: steps.create_pr.outputs.pull-request-operation == 'created'
|
|
uses: peter-evans/enable-pull-request-automerge@v3
|
|
with:
|
|
token: ${{ secrets.BOT }}
|
|
pull-request-number: ${{ steps.create_pr.outputs.pull-request-number }}
|
|
merge-method: squash
|