From 4d783c033d694d7857d219c4256085f1df416811 Mon Sep 17 00:00:00 2001 From: SeerLite Date: Thu, 30 Sep 2021 18:03:59 -0300 Subject: [PATCH] Add CI for ESLint and Prettier in PRs (#1661) --- .github/workflows/ci.yml | 46 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..fd68f3181 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,46 @@ +name: Lint and auto-format PRs + +permissions: + contents: write + +on: + pull_request: + types: [opened, synchronize] + +jobs: + lint_and_format: + name: Lint and auto-format + runs-on: ubuntu-latest + + steps: + # Checkout previous commit and then pull, to fetch everything in between + - uses: actions/checkout@v2 + with: + ref: ${{github.event.pull_request.base.sha}} + repository: ${{github.event.pull_request.head.repo.full_name}} + - run: | + git pull origin ${{github.event.pull_request.head.ref}} + git checkout ${{github.event.pull_request.head.ref}} + + - name: Setup Node.js environment + uses: actions/setup-node@v2.3.0 + with: + node-version: 14 + cache: npm + + - name: Install npm dependencies + run: npm ci + + - name: Run ESLint + run: npx gulp lint + + - name: Run Prettier + run: npx pretty-quick --branch ${{github.event.pull_request.base.sha}} + + - name: Commit and push + run: | + git config user.name "GitHub Actions Bot" + git config user.email "<>" + git add --update + git commit -m "Auto-format with Prettier" || : + git push origin HEAD:${{github.event.pull_request.head.ref}}