From ae7340181aac24500eed732c731c7decfcb58ad0 Mon Sep 17 00:00:00 2001 From: Etienne Stalmans Date: Mon, 14 Oct 2024 05:23:55 +0200 Subject: [PATCH] chore: update workflow check-conventional-commits (#962) ## What kind of change does this PR introduce? Bug fix ## What is the current behavior? Some github.event messages can break the workflow. Backticks get interpreted by the shell, this is a security risk and also breaks most Dependabot PRs. ## What is the new behavior? Updates the workflow to deal with special characters that might be interpreted by the shell ## Additional context Should fix https://github.com/supabase/auth-js/actions/runs/11035778554/job/30652617566 --- .../workflows/conventional-commits-lint.js | 2 +- .github/workflows/conventional-commits.yml | 20 +++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/.github/workflows/conventional-commits-lint.js b/.github/workflows/conventional-commits-lint.js index da9b388b6..8eb4e451e 100644 --- a/.github/workflows/conventional-commits-lint.js +++ b/.github/workflows/conventional-commits-lint.js @@ -16,7 +16,7 @@ const ALLOWED_CONVENTIONAL_COMMIT_PREFIXES = [ ]; const object = process.argv[2]; -const payload = JSON.parse(fs.readFileSync(process.stdin.fd, "utf-8")); +const payload = JSON.parse(fs.readFileSync(process.argv[3], "utf-8")); let validate = []; diff --git a/.github/workflows/conventional-commits.yml b/.github/workflows/conventional-commits.yml index f91c9b079..eeab86733 100644 --- a/.github/workflows/conventional-commits.yml +++ b/.github/workflows/conventional-commits.yml @@ -16,10 +16,15 @@ on: - reopened - ready_for_review +permissions: + contents: read + jobs: check-conventional-commits: runs-on: ubuntu-latest - + if: github.actor != 'dependabot[bot]' # skip for dependabot PRs + env: + EVENT: ${{ toJSON(github.event) }} steps: - uses: actions/checkout@v4 with: @@ -29,15 +34,14 @@ jobs: - if: ${{ github.event_name == 'pull_request_target' }} run: | set -ex - - node .github/workflows/conventional-commits-lint.js pr < "$TMP_FILE" + node .github/workflows/conventional-commits-lint.js pr "${TMP_FILE}" - if: ${{ github.event_name == 'push' }} run: | set -ex - node .github/workflows/conventional-commits-lint.js push < "$TMP_FILE" + node .github/workflows/conventional-commits-lint.js push "${TMP_FILE}"