Last active
June 10, 2024 13:44
-
-
Save NazCodeland/cc3e172488f2c22921f955592a46e11e to your computer and use it in GitHub Desktop.
This GitHub Actions workflow uses bun to automatically format your codebase whenever a push is made to the repository.
This file contains hidden or 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: Code Format | |
on: [push] | |
jobs: | |
format: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v2 | |
- name: Setup Bun | |
uses: oven-sh/setup-bun@v1 | |
- name: Install dependencies | |
run: bun install | |
- name: Run format | |
run: bun run format | |
- name: Check for modified files | |
id: git-check | |
run: echo ::set-output name=modified::$(if git diff-index --quiet HEAD --; then echo "false"; else echo "true"; fi) | |
- name: Commit and push if changed | |
run: | | |
git config --global user.name 'GitHub Action' | |
git config --global user.email '[email protected]' | |
git commit -am "Automated code formatting" | |
git push | |
if: steps.git-check.outputs.modified == 'true' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment