Skip to content

Commit 5a65682

Browse files
authored
Merge pull request #255 from rajbos/main
Adding support for different target host than the executing environment
2 parents 319b4de + ed47107 commit 5a65682

7 files changed

+157
-78
lines changed

README.md

+20
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@ A newline-delimited (`"\n"`) string representing a list of allowed [license keys
8181
8282
**Example:** `"0bsd\napache-2.0\nmit"`
8383

84+
### `targetInstanceUrl` (optional, string)
85+
86+
This parameter can be used to target a GitHub Enterprise Server instance instead of <https://github.com>.
87+
88+
**Example:** `https://my-private.github-server.com`
89+
8490
## Outputs
8591

8692
### `forkUrl` (string)
@@ -136,6 +142,20 @@ with:
136142
licenseAllowlist: "0bsd\napache-2.0\nmit"
137143
```
138144

145+
### Target a GitHub Enterprise Server
146+
147+
Create a fork in your own GitHub Enterprise Server:
148+
149+
```yaml
150+
uses: wayfair-incubator/forker@a694606ff02c8ba2654865adeb7a6d2053b34afa
151+
with:
152+
token: ${{ secrets.ACCESS_TOKEN }}
153+
repo: tremor-runtime
154+
owner: tremor-rs
155+
user: lelia
156+
targetInstanceUrl: https://my-private.github-server.com
157+
```
158+
139159
---
140160

141161
## Developing

action.yml

+3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ inputs:
3232
description: 'List of allowed licenses for repository being forked'
3333
required: false
3434
default: 'undefined'
35+
targetInstanceUrl:
36+
description: 'GitHub target instance that will have the fork'
37+
required: false
3538
outputs:
3639
forkUrl:
3740
description: 'The URL of the forked repository'

dist/index.js

+72-68
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

+44-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
"license": "MIT",
2929
"dependencies": {
3030
"@actions/core": "1.10.1",
31-
"@octokit/rest": "20.0.2"
31+
"@octokit/rest": "20.0.2",
32+
"https-proxy-agent": "^7.0.0"
3233
},
3334
"devDependencies": {
3435
"@types/jest": "28.1.8",

src/github.ts

+15-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,22 @@
11
import * as core from '@actions/core'
22
import {HTTP} from './const'
33
import {Octokit} from '@octokit/rest'
4+
import {HttpsProxyAgent} from 'https-proxy-agent'
45

56
const token: string = core.getInput('token', {required: true})
6-
const octokit = new Octokit({auth: token})
7+
const targetInstanceUrl: string = core.getInput('targetInstanceUrl')
8+
const httpsProxy: string = process.env.HTTPS_PROXY as string
9+
const octokit = targetInstanceUrl ? new Octokit({
10+
auth: token,
11+
baseUrl: targetInstanceUrl,
12+
request: {
13+
agent: httpsProxy
14+
? new HttpsProxyAgent(httpsProxy)
15+
: undefined,
16+
},
17+
}) : new Octokit({
18+
auth: token,
19+
})
720

821
export async function changeUserPermissions(
922
org: string,
@@ -84,6 +97,7 @@ export async function forkRepo(
8497
}`
8598
)
8699
} else {
100+
core.info(`Received an error code: ${err.status} ${(err as Error).message}`)
87101
core.setFailed(`🚨 Failed to create fork of repository: ${repo}`)
88102
}
89103
}

0 commit comments

Comments
 (0)