Prettier #455
This file contains 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: Prettier | |
on: | |
workflow_dispatch: | |
#Runs at 01:01 UTC | |
schedule: | |
- cron: "1 1 * * *" | |
concurrency: | |
group: "main-branch" | |
jobs: | |
format: | |
if: github.repository == 'Would-You-Bot/client' | |
runs-on: ubuntu-latest | |
name: Format Files | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: pnpm/action-setup@v2 | |
with: | |
version: latest | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: "18.x" | |
cache: "pnpm" | |
- run: pnpm i --no-frozen-lockfile | |
- name: Prettier | |
run: pnpm run format | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- uses: stefanzweifel/git-auto-commit-action@v4 | |
id: format-files | |
with: | |
commit_message: "chore(style): format files" | |
skip_checkout: true | |
branch: "formatting-${{ github.sha }}" | |
create_branch: true | |
# create PR using GitHub CLI if files were formatted | |
- name: create PR with formatted files | |
if: steps.format-files.outputs.changes_detected == 'true' | |
id: create-pr | |
run: git checkout formatting-${{ github.sha }} && gh pr create --base main --head formatting-${{ github.sha }} --title 'Merge formatting into main' --body 'Created by Github action' | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# merge PR using GitHub CLI | |
- name: merge PR with adjusted formatting | |
if: steps.format-files.outputs.changes_detected == 'true' | |
id: merge-pr | |
run: gh pr merge --admin --merge --subject 'Merge formatting' --delete-branch | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |