Skip to content

Commit

Permalink
feat: add output for merged pull requests (#113)
Browse files Browse the repository at this point in the history
Co-authored-by: Gregor Martynus <39992+gr2m@users.noreply.github.com>
  • Loading branch information
sthomson-wyn and gr2m authored Feb 13, 2025
1 parent 45c4949 commit c7e2822
Show file tree
Hide file tree
Showing 5 changed files with 1,328 additions and 1,298 deletions.
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Note that pull requests from forks are ignored for security reasons.

### Output

Currently scheduled pull requests are output by this action, available for use in later actions.
Scheduled pull requests and merged pull requests are output by this action, available for use in later actions.

The output is of the form:

Expand Down Expand Up @@ -141,6 +141,25 @@ jobs:
});
// Do something with the pull request
}
- name: Process Merged PRs
uses: actions/github-script@v6
# Only run if there are merged pull requests
if: ${{ fromJson(steps.merge-schedule.outputs.merged_pull_requests)[0] != null }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const pullRequests = JSON.parse(`${{ steps.merge-schedule.outputs.merged_pull_requests }}`);
const now = new Date();
for (const item of pullRequests) {
// Fetch the pull request details
const { data: pullRequest } = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: item.number,
});
// Do something with the pull request
}
```
## Bypassing Repository Rules
Expand Down
2 changes: 2 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@ inputs:
outputs:
scheduled_pull_requests:
description: "An array of the pull requests that are scheduled to be merged"
merged_pull_requests:
description: "An array of the pull requests that were successfully merged"
Loading

0 comments on commit c7e2822

Please sign in to comment.