docs: create GitHub action for automating labels (#725) #14
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 Lint and Format | |
on: | |
push: | |
branches: | |
- main | |
permissions: | |
contents: write | |
jobs: | |
prettier-lint-and-format: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
ref: ${{ github.event.pull_request.head.ref }} | |
repository: ${{ github.event.pull_request.head.repo.full_name }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "20.x" | |
- name: Install Dependencies | |
run: | | |
cd ./server && npm i | |
cd ../client && npm i --force | |
- name: Run ESLint and Prettier | |
working-directory: ./client | |
run: | | |
npm run lint | |
npm run format | |
- name: Check for changes | |
id: git-check | |
run: | | |
git diff --quiet || echo "has_changes=true" >> $GITHUB_OUTPUT | |
- name: Commit changes | |
if: steps.git-check.outputs.has_changes == 'true' | |
run: | | |
git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "github-actions[bot]" | |
git commit -am "style: format code with prettier and fix lint issues" | |
git add -A | |
git push |