Skip to content

Commit

Permalink
Update diff_comment.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
uniqueg authored Oct 29, 2024
1 parent 98143d2 commit dc099c8
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions .github/workflows/diff_comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,22 @@ jobs:
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: Get the PR number
id: get_pr_number
run: |
if [[ -n "${{ github.event.workflow_run.pull_requests[0].number }}" ]]; then
echo "pr_number=${{ github.event.workflow_run.pull_requests[0].number }}" >> $GITHUB_OUTPUT
else
echo "pr_number=$(jq '.workflow_run.head_repository.pull_requests[0].number' $GITHUB_EVENT_PATH)" >> $GITHUB_OUTPUT
fi
echo ${{ github.event.workflow_run.pull_requests[0].number }}
echo $(jq '.workflow_run.head_repository.pull_requests[0].number' $GITHUB_EVENT_PATH)
steps:
- name: Download diff
uses: actions/download-artifact@v4
with:
name: openapi-diff-log
name: diff-artifacts
path: diff-artifacts/
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Create PR comment
uses: actions/github-script@v7
with:
script: |
const diff = require('fs').readFileSync('diff.md', 'utf8');
const diff = require('fs').readFileSync('diff-artifacts/diff.md', 'utf8');
const pr_number = require('fs').readFileSync('diff-artifacts/pr_number', 'utf8');
github.rest.issues.createComment({
issue_number: steps.get_pr_number.outputs.pr_number,
issue_number: pr_number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '## OpenAPI diff:\n\n' + diff
Expand Down

0 comments on commit dc099c8

Please sign in to comment.