Skip to content

Commit

Permalink
use command arg for pr-sha
Browse files Browse the repository at this point in the history
  • Loading branch information
suzhoum committed Dec 18, 2024
1 parent 3b30353 commit 11aa97f
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions .github/workflows/slash_command_dispatch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,19 @@ jobs:
if: ${{ github.event.issue.pull_request }}
steps:
- name: Get PR SHA
id: sha
id: parse-args
uses: actions/github-script@v7
with:
result-encoding: string
script: |
const { owner, repo, number } = context.issue;
const pr = await github.rest.pulls.get({
owner,
repo,
pull_number: number,
});
return pr.data.head.sha
const body = context.payload.comment.body.trim();
const commandRegex = /^\/platform_tests\s+([a-f0-9]{40})$/;
const match = body.match(commandRegex);
if (!match) {
throw new Error("Invalid command format. Please provide a full 40-character SHA as an argument.");
}
console.log(`Extracted SHA: "${match[1]}"`);
return match[1];
- name: Get PR number
id: pr_number
uses: actions/github-script@v7
Expand Down Expand Up @@ -54,7 +55,7 @@ jobs:
static-args: |
repository=${{ github.repository }}
comment-id=${{ github.event.comment.id }}
pr-sha=${{ steps.sha.outputs.result }}
pr-sha=${{ steps.parse-args.outputs.result }}
branch_or_pr_number=PR-${{ steps.pr_number.outputs.result }}
fork_info=${{ steps.pr_info.outputs.FORK_NAME }}|${{ steps.pr_info.outputs.FORK_BRANCH }}
- name: Edit comment with error message
Expand Down

0 comments on commit 11aa97f

Please sign in to comment.