Skip to content

Run Prettier on entire repo #101

Run Prettier on entire repo

Run Prettier on entire repo #101

Workflow file for this run

name: Run Prettier on entire repo
on:
schedule:
- cron: '0 0 * * 1' # Once a week
workflow_dispatch: # Or manually from GitHub UI
jobs:
run_prettier:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v2
with:
node-version: "18"
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set credentials
run: |
git config --global user.email "[email protected]"
git config --global user.name "Polkadot-Kusama Bot"
- name: Check for existing branch
run: |
if [[ $(git ls-remote --heads origin refs/heads/prettier-update | wc -l) == "1" ]]; then
echo deleting existing branch
git push origin --delete prettier-update
else
echo no existing branch found
fi
- name: Project setup
run: |
git branch prettier-update
git checkout prettier-update
yarn && yarn prettier:all
- name: Commit any changes from prettier execution and make new PR
run: |
if [[ `git status --porcelain` ]]; then
git commit -a -m 'applying prettier to entire repo'
git push --set-upstream origin prettier-update
gh pr create -B master -H prettier-update --title 'Automated prettier cleanup' --body 'Automated prettier cleanup over entire repo.'
else
echo No prettier changes detected, skipping update.
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}