Skip to content
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
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,28 @@ jobs:

See the [examples workflow](.github/workflows/examples.yml) for more details and examples (and see the [associated runs](https://github.com/LouisBrunner/checks-action/actions?query=workflow%3Aexamples) to see how it will look like).

### GitHub Enterprise Server

When running on GitHub Enterprise Server, set `github_api_url` to your instance API endpoint:

```yaml
name: "build-test"
on: [push]

jobs:
test_something:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: LouisBrunner/checks-action@v2.0.0
if: always()
with:
token: ${{ secrets.GITHUB_TOKEN }}
github_api_url: https://github.example.com/api/v3
name: Test XYZ
conclusion: ${{ job.status }}
```

### Permissions

When the action is run as part of a Pull Request, your workflow might fail with the following error: `Error: Resource not accessible by integration`.
Expand Down Expand Up @@ -80,6 +102,10 @@ _Optional_ The SHA of the target commit. Defaults to the current commit.

**Required** Your `GITHUB_TOKEN`

### `github_api_url`

_Optional_ The base API URL to use for GitHub API requests. Useful for GitHub Enterprise Server, e.g. `https://github.example.com/api/v3`.

### `name`

**Required** for creation, the name of the check to create (mutually exclusive with `check_id`)
Expand Down
27 changes: 27 additions & 0 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ describe("run action", () => {
};

const runAction = async ({
githubAPIURL,
repo,
sha,
token = "ABC",
Expand All @@ -204,6 +205,7 @@ describe("run action", () => {
conclusion,
testPort,
}: {
githubAPIURL: string | undefined;
repo: string | undefined;
sha: string | undefined;
token: string | undefined;
Expand All @@ -221,6 +223,9 @@ describe("run action", () => {
}> => {
const entry = path.join(__dirname, "..", "dist", "index.js");
const optional: Record<string, unknown> = {};
if (githubAPIURL !== undefined) {
optional.INPUT_GITHUB_API_URL = githubAPIURL;
}
if (repo !== undefined) {
optional.INPUT_REPO = repo;
}
Expand Down Expand Up @@ -283,6 +288,7 @@ describe("run action", () => {
checkID?: string;
eventName?: string;
eventRecord?: Record<string, unknown>;
githubAPIURL?: string;
repo?: string;
sha?: string;
token?: string;
Expand All @@ -295,6 +301,26 @@ describe("run action", () => {

const cases = ((): Case[] => {
return [
{
checkName: "testo",
conclusion: Conclusion.Success,
expectedCheckID: 456,
expectedRequests: [
{
body: {
conclusion: "success",
head_sha: "SHA1",
name: "testo",
status: "completed",
},
method: "POST",
url: "/api/v3/repos/LB/ABC/check-runs",
},
],
githubAPIURL: "https://ghe.example.com/api/v3",
name: "creation using custom github api url",
status: Status.Completed,
},
{
checkName: "testo",
conclusion: Conclusion.Success,
Expand Down Expand Up @@ -452,6 +478,7 @@ describe("run action", () => {
conclusion: rest.conclusion.toString(),
eventName: rest.eventName,
eventPath: rest.eventRecord ? filename : undefined,
githubAPIURL: rest.githubAPIURL,
id: rest.checkID,
name: rest.checkName,
repo: rest.repo,
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ branding:
icon: 'check-circle'
color: 'green'
inputs:
github_api_url:
description: 'the base GitHub API URL (for GitHub Enterprise, e.g. https://github.example.com/api/v3)'
required: false
repo:
description: 'the target `owner/repo` to manage the check run on (defaults to the current repository)'
required: false
Expand Down
36 changes: 18 additions & 18 deletions dist/index.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/inputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const parseJSON = <T>(getInput: GetInput, property: string): T | undefined => {
};

export const parseInputs = (getInput: GetInput): Inputs.Args => {
const githubAPIURL = getInput("github_api_url");
const repo = getInput("repo");
const sha = getInput("sha");
const token = getInput("token", { required: true });
Expand Down Expand Up @@ -107,6 +108,7 @@ export const parseInputs = (getInput: GetInput): Inputs.Args => {
checkID,
conclusion,
detailsURL,
githubAPIURL,
images,
name,

Expand Down
5 changes: 4 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ async function run(): Promise<void> {
const inputs = parseInputs(core.getInput);

core.debug(`Setting up OctoKit`);
const octokit = github.getOctokit(inputs.token, options);
const octokit = github.getOctokit(inputs.token, {
...options,
baseUrl: inputs.githubAPIURL ?? options.baseUrl,
});

const ownership = {
owner: github.context.repo.owner,
Expand Down
1 change: 1 addition & 0 deletions src/namespaces/Inputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ interface ArgsBase {
annotations?: Annotations;
conclusion?: Conclusion;
detailsURL?: string;
githubAPIURL?: string;
images?: Images;

output?: Output;
Expand Down