Skip to content

Commit 0971b1a

Browse files
committed
Actions: accept the config input
The idea is to configure GitGitGadget via a `gitgitgadget-config.json` file that contains the project-specific instance of the `IConfig` interface, tracked in the `config` branch of a fork of the `gitgitgadget-workflows` repository, from where it is automatically synchronized via a GitHub workflow to the repository variable `CONFIG`, and then passed to all of GitGitGadget's Actions via: ```yml config: '${{ vars.CONFIG }}' ``` For now, this input is optional, to ease the transition of GitGitGadget; Eventually, this config will be required, so that several projects can be served using identical source code in forks of the `gitgitgadget-github-app` and `gitgitgadget-workflows` repositories. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 3e65c68 commit 0971b1a

6 files changed

Lines changed: 25 additions & 1 deletion

File tree

handle-new-mails/action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ name: 'Handle new mails'
22
description: 'Processes new mails on the Git mailing list'
33
author: 'Johannes Schindelin'
44
inputs:
5+
config:
6+
description: 'The GitGitGadget configuration to use (see https://github.com/gitgitgadget/gitgitgadget/blob/HEAD/lib/project-config.ts)'
7+
default: '' # sadly, ${{ vars.CONFIG }} does not work, and documentation about what contexts are permissible here is sorely missing
58
pr-repo-token:
69
description: 'The access token to work on the repository that holds PRs and state'
710
required: true

handle-pr-comment/action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ name: 'Handle PR Comment'
22
description: 'Handles slash commands such as /submit and /preview'
33
author: 'Johannes Schindelin'
44
inputs:
5+
config:
6+
description: 'The GitGitGadget configuration to use (see https://github.com/gitgitgadget/gitgitgadget/blob/HEAD/lib/project-config.ts)'
7+
default: '' # sadly, ${{ vars.CONFIG }} does not work, and documentation about what contexts are permissible here is sorely missing
58
pr-repo-token:
69
description: 'The access token to work on the repository that holds PRs and state'
710
required: true

handle-pr-push/action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ name: 'Handle PR Pushes'
22
description: 'Handles when a PR was pushed'
33
author: 'Johannes Schindelin'
44
inputs:
5+
config:
6+
description: 'The GitGitGadget configuration to use (see https://github.com/gitgitgadget/gitgitgadget/blob/HEAD/lib/project-config.ts)'
7+
default: '' # sadly, ${{ vars.CONFIG }} does not work, and documentation about what contexts are permissible here is sorely missing
58
pr-repo-token:
69
description: 'The access token to work on the repository that holds PRs and state'
710
required: true

lib/ci-helper.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,17 @@ export class CIHelper {
5353
return configFile ? await getExternalConfig(configFile) : getConfig();
5454
}
5555

56+
protected static getConfigAsGitHubActionInput(): IConfig | undefined {
57+
if (process.env.GITHUB_ACTIONS !== "true") return undefined;
58+
const json = core.getInput("config");
59+
if (!json) return undefined;
60+
const config = JSON.parse(json) as IConfig | undefined;
61+
if (typeof config === "object" && config.project !== undefined) return config;
62+
return undefined;
63+
}
64+
5665
public constructor(workDir: string = "pr-repo.git", config?: IConfig, skipUpdate?: boolean, gggConfigDir = ".") {
57-
this.config = config !== undefined ? setConfig(config) : getConfig();
66+
this.config = config !== undefined ? setConfig(config) : CIHelper.getConfigAsGitHubActionInput() || getConfig();
5867
this.gggConfigDir = gggConfigDir;
5968
this.workDir = workDir;
6069
this.notes = new GitNotes(workDir);

update-mail-to-commit-notes/action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ name: 'Update the mail <-> commit notes'
22
description: 'Updates the mapping between commits and patch emails, stored in the `mail-to-commit` and `commit-to-mail` Git notes refs.'
33
author: 'Johannes Schindelin'
44
inputs:
5+
config:
6+
description: 'The GitGitGadget configuration to use (see https://github.com/gitgitgadget/gitgitgadget/blob/HEAD/lib/project-config.ts)'
7+
default: '' # sadly, ${{ vars.CONFIG }} does not work, and documentation about what contexts are permissible here is sorely missing
58
pr-repo-token:
69
description: 'The access token to work on the repository that holds PRs and state'
710
required: true

update-prs/action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ name: 'Update the Pull Requests'
22
description: 'Updates the Pull Requests in response to upstream commits'
33
author: 'Johannes Schindelin'
44
inputs:
5+
config:
6+
description: 'The GitGitGadget configuration to use (see https://github.com/gitgitgadget/gitgitgadget/blob/HEAD/lib/project-config.ts)'
7+
default: '' # sadly, ${{ vars.CONFIG }} does not work, and documentation about what contexts are permissible here is sorely missing
58
pr-repo-token:
69
description: 'The access token to work on the repository that holds PRs and state'
710
required: true

0 commit comments

Comments
 (0)