Skip to content

Commit

Permalink
Introduce configurable GitHub URL (support GitHub Enterprise deployme…
Browse files Browse the repository at this point in the history
…nts)
  • Loading branch information
ruebenramirez committed Aug 26, 2021
1 parent fa2ff6b commit 0a53965
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 2 deletions.
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

0 comments on commit 0a53965

Please sign in to comment.