Skip to content

Commit

Permalink
✨ Save the PR URLs in the pull_request_urls output (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
BetaHuhn committed Oct 16, 2021
1 parent eb3b6c6 commit f9fdef0
Show file tree
Hide file tree
Showing 5 changed files with 7,905 additions and 105 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ jobs:
```
#### Token
In order for the Action to access your repositories you have to specify a [Personal Access token](https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token) as the value for `GH_PAT` (`GITHUB_TOKEN` will **not** work). The PAT needs the full repo scope ([#31](https://github.com/BetaHuhn/repo-file-sync-action/discussions/31#discussioncomment-674804)).

It is recommended to set the token as a
Expand Down Expand Up @@ -120,6 +121,10 @@ Here are all the inputs [repo-file-sync-action](https://github.com/BetaHuhn/repo
| `SKIP_CLEANUP` | Skips removing the temporary directory. Useful for debugging | **No** | false |
| `SKIP_PR` | Skips creating a Pull Request and pushes directly to the default branch | **No** | false |

### Outputs

The action sets the `pull_request_urls` output to the URLs of any created Pull Requests. It will be an array of URLs to each PR, e.g. `'["https://github.com/username/repository/pull/number", "..."]'`.

## 🛠️ Sync Configuration

In order to tell [repo-file-sync-action](https://github.com/BetaHuhn/repo-file-sync-action) what files to sync where, you have to create a `sync.yml` file in the `.github` directory of your main repository (see [action-inputs](#%EF%B8%8F-action-inputs) on how to change the location).
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ inputs:
Specify a different prefix for the new branch in the target repo. Defaults to repo-sync/SOURCE_REPO_NAME
required: false

outputs:
pull_request_urls:
description: 'The URLs to the created Pull Requests as an array'

runs:
using: 'node12'
main: 'dist/index.js'
Expand Down
11 changes: 8 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17766,6 +17766,8 @@ const run = async () => {

const repos = await parseConfig()

const prUrls = []

await forEach(repos, async (item) => {
core.info(`Repository Info`)
core.info(`Slug : ${ item.repo.name }`)
Expand Down Expand Up @@ -17908,9 +17910,7 @@ const run = async () => {
const pullRequest = await git.createOrUpdatePr(COMMIT_EACH_FILE ? changedFiles : '', useCommitAsPRTitle ? modified[0].commitMessage.split('\n', 1)[0].trim() : undefined)

core.notice(`Pull Request #${ pullRequest.number } created/updated: ${ pullRequest.html_url }`)

core.setOutput('pull_request_number', pullRequest.number)
core.setOutput('pull_request_url', pullRequest.html_url)
prUrls.push(pullRequest.html_url)

if (PR_LABELS !== undefined && PR_LABELS.length > 0) {
core.info(`Adding label(s) "${ PR_LABELS.join(', ') }" to PR`)
Expand All @@ -17930,6 +17930,11 @@ const run = async () => {
}
})

// If we created any PRs, set their URLs as the output
if (prUrls) {
core.setOutput('pull_request_urls', prUrls)
}

if (SKIP_CLEANUP === true) {
core.info('Skipping cleanup')
return
Expand Down
Loading

0 comments on commit f9fdef0

Please sign in to comment.