Skip to content

Commit 954eef5

Browse files
Jiří FenclJounQin
authored andcommitted
Add GITLAB_COMMENT_DISCUSSION_AUTORESOLVE optional environment
1 parent cac8607 commit 954eef5

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed

.changeset/swift-berries-exist.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'changesets-gitlab': minor
3+
---
4+
5+
Add GITLAB_COMMENT_DISCUSSION_AUTORESOLVE optional environment variable to automaticly resolve added discussion with options to resolve discussion by default (value `all`) or resolve only when changeset is present (value `hasChangeset`)

README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,14 @@ GLOBAL_AGENT_NO_PROXY # Like above but for no proxied requests
4848

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

51-
GITLAB_TOKEN # required, token with accessibility to push, package registries, and merge request APIs. Note the CI_JOB_TOKEN does not have sufficient permissons
52-
GITLAB_TOKEN_TYPE # optional, type of the provided token in GITLAB_TOKEN. defaults to personal access token. Can be `oauth` if you use Gitlab Oauth (personal access) token..
53-
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
54-
GITLAB_CI_USER_EMAIL # optional, default `gitlab[bot]@users.noreply.gitlab.com`
55-
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
56-
GITLAB_ADD_CHANGESET_MESSAGE # optional, default commit message for adding changesets on GitLab Web UI
57-
DEBUG_GITLAB_CREDENTIAL # optional, default `false`
51+
GITLAB_TOKEN # required, token with accessibility to push, package registries, and merge request APIs. Note the CI_JOB_TOKEN does not have sufficient permissions
52+
GITLAB_TOKEN_TYPE # optional, type of the provided token in GITLAB_TOKEN. defaults to personal access token. Can be `oauth` if you use Gitlab Oauth (personal access) token
53+
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
54+
GITLAB_CI_USER_EMAIL # optional, default `gitlab[bot]@users.noreply.gitlab.com`
55+
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
56+
GITLAB_ADD_CHANGESET_MESSAGE # optional, default commit message for adding changesets on GitLab Web UI
57+
GITLAB_COMMENT_DISCUSSION_AUTO_RESOLVE # optional, automatically resolve added discussion with options to resolve discussion by default (value `all`) or resolve only when changeset is present (value `hasChangeset`)
58+
DEBUG_GITLAB_CREDENTIAL # optional, default `false`
5859
```
5960

6061
### Example workflow

src/comment.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,8 @@ export const comment = async () => {
250250
CI_MERGE_REQUEST_SOURCE_BRANCH_SHA,
251251
CI_MERGE_REQUEST_TITLE,
252252
GITLAB_COMMENT_TYPE,
253+
GITLAB_COMMENT_DISCUSSION_AUTORESOLVE,
254+
GITLAB_COMMENT_DISCUSSION_AUTORESOLVE_ONLY_CHANGESET_EXISTS,
253255
GITLAB_ADD_CHANGESET_MESSAGE,
254256
} = env
255257

@@ -319,6 +321,7 @@ export const comment = async () => {
319321
noteInfo.noteId,
320322
{
321323
body: prComment,
324+
resolved: GITLAB_COMMENT_DISCUSSION_AUTORESOLVE === 'always' || (GITLAB_COMMENT_DISCUSSION_AUTORESOLVE === 'hasChangeset' && hasChangeset),
322325
},
323326
)
324327
}

src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export type Env = GitLabCIPredefinedVariables &
2020
GITLAB_CI_USER_NAME?: string
2121
GITLAB_CI_USER_EMAIL: string
2222
GITLAB_COMMENT_TYPE: LooseString<'discussion' | 'note'>
23+
GITLAB_COMMENT_DISCUSSION_AUTORESOLVE: LooseString<'always' | 'hasChangeset'>
2324
GITLAB_ADD_CHANGESET_MESSAGE?: string
2425
DEBUG_GITLAB_CREDENTIAL: LooseString<'1' | 'true'>
2526

0 commit comments

Comments
 (0)