From fd1304ba667fd8036ed98d69a5522b1ef53c80d3 Mon Sep 17 00:00:00 2001 From: Petros Andreou Date: Mon, 25 Sep 2023 21:28:27 +0300 Subject: [PATCH] feat: add support for GH enterprise customers (#74) --- README.md | 29 +++++++++++++++-------------- action.yml | 8 ++++++-- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 380fd87..fcfcf4e 100644 --- a/README.md +++ b/README.md @@ -38,20 +38,21 @@ Since the issues and pull requests from this repository are also managed by this ## Variables -| Variable | Required | Description | -| ------------------------ | -------- |------------ | -| `gh_token` | false | The GitHub token to use for the automation. For App instructions refer to [GH App Auth](#GH-App-Auth). (`gh_token` or `gh_app_*` must be defined) | -| `gh_app_ID` | false | The GitHub App ID used for App authentication. For App instructions refer to [GH App Auth](#GH-App-Auth). (`gh_token` or `gh_app_*` must be defined) | -| `gh_app_installation_ID` | false | The Github App installation ID binding the App to the target org. For App instructions refer to [GH App Auth](#GH-App-Auth). (`gh_token` or `gh_app_*` must be defined) | -| `gh_app_secret_key` | false | The Github App Secret key used to sign App JWT tokens. For App instructions refer to [GH App Auth](#GH-App-Auth). (`gh_token` or `gh_app_*` must be defined) | -| `user` | false | The GitHub username that owns the projectboard. Either a user or an organization must be specified. | -| `organization` | false | The GitHub organization that owns the projectboard. Either a user or an organization must be specified. | -| `project_id` | true | The projectboard id. | -| `resource_node_id` | true | The id of the resource node. | -| `status_value` | false | The status value to set. Must be one of the values defined in your project board **Status field settings**. If left unspecified, new items are added without an explicit status, and existing items are left alone. | -| `operation_mode` | false | The operation mode to use. Must be one of `custom_field`, `status`. Defaults to: `status` | -| `custom_field_values` | false | Provides the possibility to change custom fields. To be applied the **operation_mode** must be set to `custom_field`. For the json definition refer to [JSON-Definition](#JSON-Definition) | -| `move_related_issues` | false | If set to `true` and the operation mode is set to `status`, the automation will also move related issues to the same column. This is useful if you want to move an issue to the same column as its related pull request. Defaults to: `false` | +| Variable | Required | Description | +|--------------------------| -------- |----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `gh_host` | false | The GitHub hostname of the enterpise installation to use for the automation. For App instructions refer to [GH App Auth](#GH-App-Auth). | +| `gh_token` | false | The GitHub token to use for the automation. For App instructions refer to [GH App Auth](#GH-App-Auth). (`gh_token` or `gh_app_*` must be defined) | +| `gh_app_ID` | false | The GitHub App ID used for App authentication. For App instructions refer to [GH App Auth](#GH-App-Auth). (`gh_token` or `gh_app_*` must be defined) | +| `gh_app_installation_ID` | false | The Github App installation ID binding the App to the target org. For App instructions refer to [GH App Auth](#GH-App-Auth). (`gh_token` or `gh_app_*` must be defined) | +| `gh_app_secret_key` | false | The Github App Secret key used to sign App JWT tokens. For App instructions refer to [GH App Auth](#GH-App-Auth). (`gh_token` or `gh_app_*` must be defined) | +| `user` | false | The GitHub username that owns the projectboard. Either a user or an organization must be specified. | +| `organization` | false | The GitHub organization that owns the projectboard. Either a user or an organization must be specified. | +| `project_id` | true | The projectboard id. | +| `resource_node_id` | true | The id of the resource node. | +| `status_value` | false | The status value to set. Must be one of the values defined in your project board **Status field settings**. If left unspecified, new items are added without an explicit status, and existing items are left alone. | +| `operation_mode` | false | The operation mode to use. Must be one of `custom_field`, `status`. Defaults to: `status` | +| `custom_field_values` | false | Provides the possibility to change custom fields. To be applied the **operation_mode** must be set to `custom_field`. For the json definition refer to [JSON-Definition](#JSON-Definition) | +| `move_related_issues` | false | If set to `true` and the operation mode is set to `status`, the automation will also move related issues to the same column. This is useful if you want to move an issue to the same column as its related pull request. Defaults to: `false` | ## Getting started diff --git a/action.yml b/action.yml index f8d1357..eb09db8 100644 --- a/action.yml +++ b/action.yml @@ -1,6 +1,10 @@ name: "project beta automations" description: 'GitHub ProjectV2/Project-Beta automation. It supports management of status and custom fields.' inputs: + gh_host: + description: 'The hostname will be used by gh-cli. This works for enterprise customers.' + required: false + default: "api.github.com" gh_token: description: 'Permission token that grants permission to the GitHub API. (Toke or App config is required)' required: false @@ -79,12 +83,12 @@ runs: - name: "Authenticate gh cli Github App" if: inputs.gh_app_secret_key != '' && inputs.gh_app_ID != '' && inputs.gh_app_installation_ID shell: bash - run: "${{ github.action_path }}/gh_app_credential_helper.sh \"${{ inputs.gh_app_secret_key }}\" \"${{ inputs.gh_app_ID }}\" \"${{ inputs.gh_app_installation_ID }}\" | gh auth login --with-token" + run: "${{ github.action_path }}/gh_app_credential_helper.sh \"${{ inputs.gh_app_secret_key }}\" \"${{ inputs.gh_app_ID }}\" \"${{ inputs.gh_app_installation_ID }}\" | gh auth login --with-token --hostname \"${{ inputs.gh_host }}\"" - name: "Authenticate gh cli PAT" if: inputs.gh_token != '' shell: bash - run: echo "${{ inputs.gh_token }}" | gh auth login --with-token + run: echo "${{ inputs.gh_token }}" | gh auth login --with-token --hostname "${{ inputs.gh_host }}" - name: "Check if User or Organization is set" if: inputs.organization == '' && inputs.user == ''