Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce configurable GITHUB_SERVER (support GitHub Enterprise deployments) #117

Merged
merged 1 commit into from
Aug 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ A Github Action that can sync files from one repository to many others. This act

**Required** Token to use to get repos and write secrets. `${{secrets.GITHUB_TOKEN}}` will **not** work.

### `GITHUB_SERVER`

Configurable GitHub Server (to support GitHub Enterprise deployments). If not specified, will default to `github.com`. Should not include `http(s)://`. Should also not include trailing `/` character.

### `SRC_REPO`

Source of truth for all files to sync. If files get added, modified or deleted here, those changes will be synced to all TARGET_REPOS. Defaults to the workflows repository (`$GITHUB_REPOSITORY`). A custom branch can be defined by adding the branchname after a colon behind the SRC_REPO. `repoSlug` or `repoSlug:branchName`
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ inputs:
GITHUB_TOKEN:
description: Token to use to get repos and write secrets
required: true
GITHUB_SERVER:
description: |
Specify a GitHub Server other than github.com (for GitHub Enterprise deployment support)
required: false
GIT_EMAIL:
description: |
The e-mail address used to commit the synced files. Defaults to $GITHUB_ACTOR@users.noreply.github.com
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const context = {
(s) => new RegExp(s)
),
GITHUB_TOKEN: core.getInput("GITHUB_TOKEN", { required: true }),
GITHUB_SERVER: core.getInput("GITHUB_SERVER", { required: false }) || "github.com",
GIT_EMAIL:
core.getInput("GIT_EMAIL") ||
`${process.env.GITHUB_ACTOR}@users.noreply.github.com`,
Expand Down
3 changes: 2 additions & 1 deletion src/git.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const { parse: porcelainParse } = require("@putout/git-status-porcelain");

const {
GITHUB_TOKEN,
GITHUB_SERVER,
SRC_REPO,
COMMIT_MESSAGE,
GIT_USERNAME,
Expand Down Expand Up @@ -54,7 +55,7 @@ module.exports = {
"git clone",
"--depth 1",
getRepoBranch() === undefined ? false : ` -b ${getRepoBranch()}`,
`https://${GITHUB_TOKEN}@github.com/${getRepoSlug()}.git`,
`https://${GITHUB_TOKEN}@${GITHUB_SERVER}/${getRepoSlug()}.git`,
getRepoPath(),
];
return execCmd(command.filter(Boolean).join(" "));
Expand Down