diff --git a/.github/merge-queue-ci-skipper/action.yml b/.github/merge-queue-ci-skipper/action.yml index 3a2474a6d..18783bb80 100644 --- a/.github/merge-queue-ci-skipper/action.yml +++ b/.github/merge-queue-ci-skipper/action.yml @@ -34,13 +34,13 @@ runs: using: 'composite' steps: - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 with: fetch-depth: 0 - name: Extract PR Number and Commit ID id: extract-pr-info - uses: actions/github-script@v7 + uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0 with: script: | const githubRef = process.env.GITHUB_REF; @@ -90,20 +90,26 @@ runs: - name: Print PR Branch if: env.CAN_SKIP_CHECKS != 'false' shell: bash + env: + PR_BRANCH: ${{ steps.get-pr-branch.outputs.prBranch }} run: | - echo "PR Branch: ${{ steps.get-pr-branch.outputs.prBranch }}" + echo "PR Branch: $PR_BRANCH" - name: Check if PR branch contains the Merge Queue target commit ID if: env.CAN_SKIP_CHECKS != 'false' shell: bash + env: + PR_BRANCH: ${{ steps.get-pr-branch.outputs.prBranch }} + COMMIT_ID: ${{ steps.extract-pr-info.outputs.commitId }} + TARGET_BRANCH: ${{ steps.extract-pr-info.outputs.targetBranchName }} run: | # Get the branch name from previous steps - branch_name="origin/${{ steps.get-pr-branch.outputs.prBranch }}" - commit_id="${{ steps.extract-pr-info.outputs.commitId }}" + branch_name="origin/$PR_BRANCH" + commit_id="$COMMIT_ID" # Check if the branch history contains the commit - if git branch -r --contains "$commit_id" | grep -q "$branch_name"; then - echo "Branch '$branch_name' contains commit '$commit_id'. It is up to date with ${{ steps.extract-pr-info.outputs.targetBranchName }}." + if git branch -r --contains "$commit_id" | grep -qF "$branch_name"; then + echo "Branch '$branch_name' contains commit '$commit_id'. It is up to date with $TARGET_BRANCH." else echo "Branch '$branch_name' does not contain commit '$commit_id'. It is outdated. Setting CAN_SKIP_CHECKS to false." echo "CAN_SKIP_CHECKS=false" >> "$GITHUB_ENV" @@ -112,8 +118,10 @@ runs: - name: Compare PR Branch with Current Branch if: env.CAN_SKIP_CHECKS != 'false' shell: bash + env: + PR_BRANCH: ${{ steps.get-pr-branch.outputs.prBranch }} run: | - if git diff --quiet "origin/${{ steps.get-pr-branch.outputs.prBranch }}"; then + if git diff --quiet "origin/$PR_BRANCH"; then echo "No differences found. PR branch is identical with this merge queue branch." else echo "Differences detected. PR branch has been updated after PR was added to merge queue. Setting CAN_SKIP_CHECKS to false." @@ -122,9 +130,11 @@ runs: - name: Compute/publish skip result id: passed-checks - uses: actions/github-script@v7 + uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0 env: SECRET: ${{ inputs.secret }} + PR_BRANCH: ${{ steps.get-pr-branch.outputs.prBranch }} + TARGET_BRANCH: ${{ steps.extract-pr-info.outputs.targetBranchName }} with: github-token: ${{ inputs.secret != '' && inputs.secret || github.token }} script: | @@ -144,7 +154,7 @@ runs: const { data: branchProtection } = await github.rest.repos.getBranchProtection({ owner: context.repo.owner, repo: context.repo.repo, - branch: "${{ steps.extract-pr-info.outputs.targetBranchName }}", + branch: process.env.TARGET_BRANCH, }); const requiredCheckNames = branchProtection.required_status_checks.contexts; console.log(`requiredCheckNames = ${requiredCheckNames}`); @@ -152,7 +162,7 @@ runs: const { data: checks } = await github.rest.checks.listForRef({ owner: context.repo.owner, repo: context.repo.repo, - ref: "refs/heads/${{ steps.get-pr-branch.outputs.prBranch }}", + ref: `refs/heads/${process.env.PR_BRANCH}`, }); console.log(`checks.check_runs = ${checks.check_runs.map(check => `${check.status},${check.conclusion},${check.name};`)}`); diff --git a/.github/workflows/cmd-deploy.yml b/.github/workflows/cmd-deploy.yml index 010359a2e..bde79ac0f 100644 --- a/.github/workflows/cmd-deploy.yml +++ b/.github/workflows/cmd-deploy.yml @@ -5,6 +5,10 @@ on: repository_dispatch: types: [deploy-command] +permissions: + contents: read + actions: read + jobs: deploy: uses: SparkUniverse/workflows/.github/workflows/deploy-command.yaml@main diff --git a/.github/workflows/slash-cmds.yml b/.github/workflows/slash-cmds.yml index 65a6d8df2..e35babedd 100644 --- a/.github/workflows/slash-cmds.yml +++ b/.github/workflows/slash-cmds.yml @@ -4,6 +4,8 @@ on: issue_comment: types: [created] +permissions: {} + jobs: dispatch-command: if: ${{ github.event.sender.type == 'User' && contains(fromJSON('["OWNER", "MEMBER"]'), github.event.comment.author_association) }}