Skip to content

Commit

Permalink
fixup! feat(ci): pr diff
Browse files Browse the repository at this point in the history
  • Loading branch information
samugi committed Aug 12, 2024
1 parent 9f7b0de commit 339bb2b
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions .github/workflows/pr-diff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,35 @@ jobs:
echo "Comment does not match format: '/prdiff <pr_url>': ignoring"
fi
- name: Get current PR URL
- name: Validate input
if: steps.read_comment.outputs.other_pr
id: validate_url
uses: actions/github-script@v7
with:
script: |
const url = `${{ steps.read_comment.outputs.other_pr }}`;
try {
const validUrl = new URL(url);
// Check if URL is a GitHub PR URL
const regex = /^https:\/\/github\.com\/[^\/]+\/[^\/]+\/pull\/\d+$/;
if (!regex.test(validUrl.href)) {
core.setFailed('The provided URL is not a valid GitHub PR URL.');
}
} catch (error) {
core.setFailed('The provided URL is not valid.');
}
- name: Get current PR URL
if: success() && steps.read_comment.outputs.other_pr
id: get_pr_url
run: |
PR_URL="https://github.com/${{ github.repository }}/pull/${{ github.event.issue.number }}"
echo "PR_URL=$PR_URL" >> $GITHUB_OUTPUT
- name: Obtain diff with the PR provided
if: steps.read_comment.outputs.other_pr
if: success() && steps.read_comment.outputs.other_pr
id: run_extension
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down

0 comments on commit 339bb2b

Please sign in to comment.