Skip to content

Commit

Permalink
feat: add custom commit_message support for adding changeset on Web UI
Browse files Browse the repository at this point in the history
  • Loading branch information
JounQin committed Dec 4, 2023
1 parent b82137c commit 9a1e492
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,13 @@ GLOBAL_AGENT_NO_PROXY # Like above but for no proxied requests

GITLAB_HOST # optional, if you're using custom GitLab host, will fallback to `CI_SERVER_URL` if not provided

GITLAB_TOKEN # required, token with accessibility to push
GITLAB_TOKEN_TYPE # optional, type of the provided token in GITLAB_TOKEN. defaults to personal access token. can be `job` if you provide the Gitlab CI_JOB_TOKEN or `oauth` if you use Gitlab Oauth token
GITLAB_CI_USER_NAME # optional, username with accessibility to push, used in pairs of the above token (if it was personal access token). If not set read it from the Gitlab API
GITLAB_CI_USER_EMAIL # optional, default `gitlab[bot]@users.noreply.gitlab.com`
GITLAB_COMMENT_TYPE # optional, type of the comment. defaults to `discussion`. can be set to `note` to not create a discussion instead of a thread
DEBUG_GITLAB_CREDENTIAL # optional, default `false`
GITLAB_TOKEN # required, token with accessibility to push
GITLAB_TOKEN_TYPE # optional, type of the provided token in GITLAB_TOKEN. defaults to personal access token. can be `job` if you provide the Gitlab CI_JOB_TOKEN or `oauth` if you use Gitlab Oauth token
GITLAB_CI_USER_NAME # optional, username with accessibility to push, used in pairs of the above token (if it was personal access token). If not set read it from the Gitlab API
GITLAB_CI_USER_EMAIL # optional, default `gitlab[bot]@users.noreply.gitlab.com`
GITLAB_COMMENT_TYPE # optional, type of the comment. defaults to `discussion`. can be set to `note` to not create a discussion instead of a thread
GITLAB_ADD_CHANGESET_MESSAGE # optional, default commit message for adding changesets on GitLab Web UI
DEBUG_GITLAB_CREDENTIAL # optional, default `false`
```

### Example workflow
Expand Down
7 changes: 6 additions & 1 deletion src/comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ export const comment = async () => {
CI_MERGE_REQUEST_SOURCE_BRANCH_SHA,
CI_MERGE_REQUEST_TITLE,
GITLAB_COMMENT_TYPE,
GITLAB_ADD_CHANGESET_MESSAGE,
} = env

if (mrBranch.startsWith('changeset-release')) {
Expand Down Expand Up @@ -199,7 +200,11 @@ export const comment = async () => {
)}.md&file=${getNewChangesetTemplate(
changedPackages,
CI_MERGE_REQUEST_TITLE,
)}`
)}${
GITLAB_ADD_CHANGESET_MESSAGE
? '&commit_message=' + encodeURIComponent(GITLAB_ADD_CHANGESET_MESSAGE)
: ''
}`

const prComment =
(hasChangeset
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export type Env = GitLabCIPredefinedVariables &
GITLAB_CI_USER_NAME?: string
GITLAB_CI_USER_EMAIL: string
GITLAB_COMMENT_TYPE: LooseString<'discussion' | 'note'>
GITLAB_ADD_CHANGESET_MESSAGE?: string
DEBUG_GITLAB_CREDENTIAL: LooseString<'1' | 'true'>

HOME: string
Expand Down

0 comments on commit 9a1e492

Please sign in to comment.