Skip to content

Commit

Permalink
Merge pull request #469 from fjogeleit/enterprise-support
Browse files Browse the repository at this point in the history
New input to customize GitHub API
  • Loading branch information
fjogeleit authored Mar 10, 2022
2 parents cd0991c + 8e8c9cf commit 36a4fc4
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 5 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# YAML Update Action

Update a single value in an existing YAML File. Push this updated YAML to an existing branch or create a new branch. Open a PullRequest to an configurable targetBranch. It is also posible to change the file locally without commiting the change.
Update a single value in an existing YAML File. Push this updated YAML to an existing branch or create a new branch. Open a PullRequest to a configurable targetBranch. It is also posible to change the file locally without commiting the change.


## Use Cases
Expand Down Expand Up @@ -95,6 +95,7 @@ jobs:
|labels| Comma separated list of labels, e.g. "feature, yaml-updates" | 'yaml-updates'|
|createPR| Create a PR from __branch__ to __targetBranch__. Use 'true' to enable it | true |
|targetBranch| Opens a PR from __branch__ to __targetBranch__ if createPR is set to 'true' | master |
|githubAPI| BaseURL for all GitHub REST API requests | https://api.github.com |
|token| GitHub API Token which is used to create the PR, have to have right permissions for the selected repository | ${{github.token}}|
|updateFile| By default the actual file is not updated, to do so set this property to 'true' | false |
|workDir| relative location of the configured `repository` | . |
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ inputs:
required: false
description: 'Target Branch for the created PullRequest'
default: master
githubAPI:
required: false
description: 'GitHub BaseURL'
default: https://api.github.com
createPR:
required: false
description: 'Create a PullRequest to the configured target branch'
Expand Down
8 changes: 7 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": "typescript-action",
"version": "0.7.1",
"version": "0.8.0",
"private": true,
"description": "TypeScript template action",
"main": "lib/main.js",
Expand Down
2 changes: 1 addition & 1 deletion src/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ ${newYamlContent}
return
}

const octokit = new Octokit({auth: options.token})
const octokit = new Octokit({auth: options.token, baseUrl: options.githubAPI})

const file: ChangedFile = {
relativePath: options.valueFile,
Expand Down
9 changes: 9 additions & 0 deletions src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface Options {
labels: string[]
targetBranch: string
repository: string
githubAPI: string
createPR: boolean
workDir: string
}
Expand Down Expand Up @@ -53,6 +54,10 @@ export class GitHubOptions implements Options {
return core.getInput('repository')
}

get githubAPI(): string {
return core.getInput('githubAPI')
}

get createPR(): boolean {
return core.getInput('createPR') === 'true'
}
Expand Down Expand Up @@ -156,6 +161,10 @@ export class EnvOptions implements Options {
return process.env.REPOSITORY || ''
}

get githubAPI(): string {
return process.env.GITHUB_API || 'https://api.github.com'
}

get workDir(): string {
return process.env.WORK_DIR || '.'
}
Expand Down

0 comments on commit 36a4fc4

Please sign in to comment.