From b364324fa59307280771ceefd5e258235358cc20 Mon Sep 17 00:00:00 2001 From: Minh Cung Date: Tue, 30 Apr 2024 16:00:17 +1000 Subject: [PATCH] format workflow --- .github/workflows/format.yml | 52 ++++++++++++++++++++++++++++++++++++ .github/workflows/test.yml | 2 +- 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/format.yml diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 0000000..6769991 --- /dev/null +++ b/.github/workflows/format.yml @@ -0,0 +1,52 @@ +name: Code Format + +on: + push: + branches: + - 'main' + workflow_dispatch: + +jobs: + prettier: + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [20.x] + + steps: + - uses: actions/checkout@v4 + - name: pnpm install + uses: './.github/actions/install_deps' + with: + node-version: ${{ matrix.node-version }} + - name: Restore prettier cache + uses: actions/cache/restore@v4 + with: + path: .cache/prettier + key: prettier-main-cache + + - name: Format + run: pnpm format + continue-on-error: true + + - name: Remove cache + if: github.event_name == 'push' + env: + GH_TOKEN: ${{ github.token }} + GH_REPO: ${{ github.event.repository.full_name }} + run: | + gh api --method DELETE /repos/{owner}/{repo}/actions/caches?key=prettier-main-cache || + echo "Cache not found" + + - name: Save Cache + if: github.event_name == 'push' + uses: actions/cache/save@v4 + with: + path: .cache/prettier + key: prettier-main-cache + + - name: Commit and Push + if: github.event_name != 'push' + uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: Apply Prettier diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ab11a61..d0728dc 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,7 +8,7 @@ on: # merge_group: workflow_dispatch: pull_request: - branches: [master] + branches: [main] types: [auto_merge_enabled, ready_for_review] jobs: