Skip to content

Commit

Permalink
Merge pull request #230 from lelia/set-fork-url-output
Browse files Browse the repository at this point in the history
Set forkUrl as Output Value
  • Loading branch information
lelia authored Oct 12, 2022
2 parents 10ce5a8 + 7abec85 commit f23a86b
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 9 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ All notable changes to `Forker` will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.0.6] - 2022-10-12

### Added

- A new GitHub Action `output` which allows the value of the `forkUrl` string to be accessed by subsequent steps in a GitHub Workflow.

### Changed

- Upgraded action runner config to use node v16 (support for v12 is [being deprecated](https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/)).

## [0.0.5] - 2022-09-07

### Added
Expand Down
22 changes: 18 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ If the `checkUser` option is enabled, `forker` will check the specified GitHub o

For legal and compliance reasons, organizations or individuals can choose to provide an optional `licenseAllowlist` to compare against the [license of the repository](https://docs.github.com/en/rest/reference/licenses) being forked. If the license key returned by the GitHub API is not found within the provided allowlist, `forker` will exit without forking the repository, and display an error.

---

## Inputs

### `token` (string, required)
Expand Down Expand Up @@ -79,14 +81,24 @@ A newline-delimited (`"\n"`) string representing a list of allowed [license keys
**Example:** `"0bsd\napache-2.0\nmit"`

## Outputs

### `forkUrl` (string)

A string representing the HTTPS URL of the newly-forked repository.

**Example:** `"https://github.com/wayfair-contribs/tremor-runtime"`

---

## Usage

### Typical

In most cases, you'll want to use the latest stable version (eg. `v0.0.5`):
In most cases, you'll want to use the latest stable version (eg. `v0.0.6`):

```yaml
uses: wayfair-incubator/forker@v0.0.5
uses: wayfair-incubator/forker@v0.0.6
with:
token: ${{ secrets.ACCESS_TOKEN }}
repo: tremor-runtime
Expand All @@ -112,7 +124,7 @@ with:
If you are automating the creation of forks on behalf of a GitHub organization with many users, you may wish to leverage the optional `checkUser`, `promoteUser`, and `licenseAllowlist` params:

```yaml
uses: wayfair-incubator/forker@v0.0.5
uses: wayfair-incubator/forker@v0.0.6
with:
token: ${{ secrets.ACCESS_TOKEN }}
repo: tremor-runtime
Expand All @@ -124,6 +136,8 @@ with:
licenseAllowlist: "0bsd\napache-2.0\nmit"
```

---

## Developing

> 💡 **Tip:** Please use [node.js](https://nodejs.org/en/download/releases/) v17.x or later, as well as [TypeScript](https://www.npmjs.com/package/typescript) v4.x or later.
Expand Down Expand Up @@ -167,7 +181,7 @@ Then run [ncc](https://github.com/zeit/ncc) and push the results:
npm run package
git add dist
git commit -a -m "prod dependencies"
git push origin releases/v0.0.5
git push origin releases/v0.0.6
```

> 💡 **Tip:** We recommend using the `--license` option for `ncc`, which will create a license file for all of the production node modules used in your project.
Expand Down
5 changes: 4 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ inputs:
description: 'List of allowed licenses for repository being forked'
required: false
default: 'undefined'
outputs:
forkUrl:
description: 'The URL of the forked repository'
runs:
using: 'node12'
using: 'node16'
main: 'dist/index.js'
3 changes: 2 additions & 1 deletion dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "forker",
"version": "0.0.5",
"version": "0.0.6",
"private": true,
"description": "Github action for automating fork creation",
"main": "lib/main.js",
Expand Down
3 changes: 2 additions & 1 deletion src/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ export async function forkRepo(
`If this was not intentional, please check for exisiting repositories on your Github account or organization!\n`
)
}
core.info(`🎉 Forked repository now available at: ${res.data.html_url}`)
core.info(`🎉 Forked repository now available at: ${url}`)
core.setOutput('forkUrl', url)
}
} catch (err: any) {
if (err.status === HTTP.FORBIDDEN) {
Expand Down

0 comments on commit f23a86b

Please sign in to comment.