diff --git a/.github/actions/pnpm-format.yml b/.github/actions/pnpm-format.yml new file mode 100644 index 000000000..a202c3cce --- /dev/null +++ b/.github/actions/pnpm-format.yml @@ -0,0 +1,36 @@ +name: pnpm format + +on: + workflow_call: + +jobs: + run: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.head_ref }} + fetch-depth: 20 + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: 20 + + - name: Setup PNPM + uses: pnpm/action-setup@v3 + with: + version: 9 + run_install: false + + - run: pnpm format + + - name: Commit back + uses: 0xsequence/actions/git-commit@v0.0.4 + env: + API_TOKEN_GITHUB: ${{ secrets.GH_TOKEN_GIT_COMMIT }} + with: + files: "**/*.js **/*.ts" + branch: ${{ github.head_ref }} + commit_message: "[AUTOMATED] pnpm format" diff --git a/.github/workflows/pr:pnpm-format-label.yml b/.github/workflows/pr:pnpm-format-label.yml new file mode 100644 index 000000000..b7acebedb --- /dev/null +++ b/.github/workflows/pr:pnpm-format-label.yml @@ -0,0 +1,23 @@ +name: pnpm-format-label + +on: + pull_request: + types: [labeled] + +jobs: + proto: + if: ${{ github.event.label.name == 'pnpm format' }} + uses: ./.github/actions/pnpm-format.yml + secrets: inherit + + rm: + if: ${{ github.event.label.name == 'pnpm format' }} + runs-on: ubuntu-latest + steps: + - name: Remove the label + run: | + LABEL=$(echo "${{ github.event.label.name }}" | sed 's/ /%20/g') + curl -X DELETE \ + -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ + -H "Accept: application/vnd.github.v3+json" \ + https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels/$LABEL