@ckeditor/ckeditor5-dev-ci 53.3.2 → 53.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +115 -1
- package/bin/circle-disable-auto-cancel-builds.js +21 -13
- package/bin/circle-enable-auto-cancel-builds.js +21 -13
- package/bin/circle-workflow-notifier.js +16 -34
- package/bin/is-job-triggered-by-member.js +30 -21
- package/bin/notify-circle-status.js +53 -25
- package/bin/trigger-circle-build.js +32 -22
- package/package.json +1 -2
package/README.md
CHANGED
|
@@ -8,7 +8,121 @@ Utils for [CKEditor 5](https://ckeditor.com) CI builds.
|
|
|
8
8
|
|
|
9
9
|
Contains tools for sending Slack notifications by Travis or Circle CI.
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
## Available scripts
|
|
12
|
+
|
|
13
|
+
These commands accept a mix of environment variables and command line arguments. Environment variables are preferred when the value comes from the CI environment or is sensitive (like tokens). Command line arguments are preferred when the value is static or local to a given repository.
|
|
14
|
+
|
|
15
|
+
> [!WARNING]
|
|
16
|
+
> Tokens are passed as environment variables to avoid exposing sensitive credentials in shell history, CI logs, or shared configuration files.
|
|
17
|
+
|
|
18
|
+
- ⚙️ **`ckeditor5-dev-ci-circle-disable-auto-cancel-builds`**
|
|
19
|
+
|
|
20
|
+
Disables the _“Auto-cancel redundant workflows”_ option in CircleCI for a given repository.
|
|
21
|
+
Useful during release processes to prevent CircleCI from canceling the workflow triggered by the release commit itself.
|
|
22
|
+
|
|
23
|
+
**Environment variables:**
|
|
24
|
+
- `CKE5_CIRCLE_TOKEN` — CircleCI API token used for authentication.
|
|
25
|
+
|
|
26
|
+
**Parameters:**
|
|
27
|
+
- `--organization` — GitHub organization name.
|
|
28
|
+
- `--repository` — GitHub repository name.
|
|
29
|
+
|
|
30
|
+
- ⚙️ **`ckeditor5-dev-ci-circle-enable-auto-cancel-builds`**
|
|
31
|
+
|
|
32
|
+
Enables the _“Auto-cancel redundant workflows”_ option in CircleCI for a given repository.
|
|
33
|
+
Should be used after a release workflow that temporarily disables this option using the `ckeditor5-dev-ci-circle-disable-auto-cancel-builds` script.
|
|
34
|
+
|
|
35
|
+
**Environment variables:**
|
|
36
|
+
- `CKE5_CIRCLE_TOKEN` — CircleCI API token used for authentication.
|
|
37
|
+
|
|
38
|
+
**Parameters:**
|
|
39
|
+
- `--organization` — GitHub organization name.
|
|
40
|
+
- `--repository` — GitHub repository name.
|
|
41
|
+
|
|
42
|
+
- ⚙️ **`ckeditor5-dev-ci-circle-workflow-notifier`**
|
|
43
|
+
|
|
44
|
+
Waits for all jobs in the **current CircleCI workflow** to finish (success or error) and then runs a final command (the "notifier").
|
|
45
|
+
Intended to run as a **dedicated job** in your workflow. The script itself handles waiting – you typically don’t add `requires` on this job.
|
|
46
|
+
|
|
47
|
+
**Environment variables:**
|
|
48
|
+
- `CKE5_CIRCLE_TOKEN` — CircleCI API token used for authentication.
|
|
49
|
+
|
|
50
|
+
**CircleCI-provided variables:**
|
|
51
|
+
- `CIRCLE_WORKFLOW_ID` — ID of the current workflow.
|
|
52
|
+
- `CIRCLE_JOB` — Name of the current job.
|
|
53
|
+
|
|
54
|
+
**Parameters:**
|
|
55
|
+
- `--task` — Command to execute at the end; default: `pnpm ckeditor5-dev-ci-notify-circle-status`.
|
|
56
|
+
- `--ignore` — Job name to ignore when waiting (repeatable; can be passed multiple times).
|
|
57
|
+
|
|
58
|
+
- ⚙️ **`ckeditor5-dev-ci-is-job-triggered-by-member`**
|
|
59
|
+
|
|
60
|
+
Verifies that a **CircleCI approval job** was approved by a user who belongs to a specified GitHub team.
|
|
61
|
+
Uses CircleCI and GitHub APIs to check the approver against the team membership.
|
|
62
|
+
|
|
63
|
+
**Environment variables:**
|
|
64
|
+
- `CKE5_CIRCLE_TOKEN` — CircleCI API token used for authentication.
|
|
65
|
+
- `CKE5_GITHUB_TOKEN` — GitHub token used to query team membership.
|
|
66
|
+
|
|
67
|
+
**CircleCI-provided variables:**
|
|
68
|
+
- `CIRCLE_WORKFLOW_ID` — ID of the current workflow.
|
|
69
|
+
|
|
70
|
+
**Parameters:**
|
|
71
|
+
- `--job` — Name of the approval job to verify.
|
|
72
|
+
- `--organization` — GitHub organization name.
|
|
73
|
+
- `--team` — GitHub team name (slug) to validate against.
|
|
74
|
+
|
|
75
|
+
- ⚙️ **`ckeditor5-dev-ci-is-workflow-restarted`**
|
|
76
|
+
|
|
77
|
+
Checks whether the current CircleCI workflow has been **restarted**.
|
|
78
|
+
If a restart is detected, the script exits with a zero exit code, allowing the pipeline to continue conditionally.
|
|
79
|
+
|
|
80
|
+
**Environment variables:**
|
|
81
|
+
- `CKE5_CIRCLE_TOKEN` — CircleCI API token used for authentication.
|
|
82
|
+
|
|
83
|
+
**CircleCI-provided variables:**
|
|
84
|
+
- `CIRCLE_WORKFLOW_ID` — ID of the current workflow (set by CircleCI).
|
|
85
|
+
|
|
86
|
+
- ⚙️ **`ckeditor5-dev-ci-notify-circle-status`**
|
|
87
|
+
|
|
88
|
+
Sends a Slack notification summarizing the current CircleCI build/workflow status.
|
|
89
|
+
For failed builds, fetches the commit author via the GitHub API (works with private repositories).
|
|
90
|
+
|
|
91
|
+
**Environment variables:**
|
|
92
|
+
- `CKE5_GITHUB_TOKEN` — GitHub token with the `repo` scope, used to fetch commit author.
|
|
93
|
+
- `CKE5_CIRCLE_TOKEN` — CircleCI API token used for API calls.
|
|
94
|
+
- `CKE5_SLACK_WEBHOOK_URL` — Incoming Webhook URL for the Slack channel receiving notifications.
|
|
95
|
+
|
|
96
|
+
**CircleCI-provided variables:**
|
|
97
|
+
- `CIRCLE_BRANCH` — The number of the current build.
|
|
98
|
+
- `CIRCLE_PROJECT_REPONAME` — Repository name.
|
|
99
|
+
- `CIRCLE_PROJECT_USERNAME` — Organization/user name.
|
|
100
|
+
- `CIRCLE_SHA1` — Commit SHA of the current build.
|
|
101
|
+
- `CIRCLE_WORKFLOW_ID` — ID of the current workflow.
|
|
102
|
+
|
|
103
|
+
**Parameters:**
|
|
104
|
+
- `--pipeline-id` &mdash Value of Circle's `<< pipeline.number >>` parameter ([read more](https://circleci.com/docs/guides/orchestrate/pipeline-variables/#pipeline-values)).
|
|
105
|
+
- `--trigger-repository-slug` — `<org>/<repo>` to construct the commit URL when provided with `--trigger-commit-hash`. Useful when a pipeline was triggered via a different repository.
|
|
106
|
+
- `--trigger-commit-hash` — Commit SHA to construct the commit URL. Useful when a pipeline was triggered via a different repository.
|
|
107
|
+
- `--hide-author` — `"true"`/`"false"` to hide the author in Slack.
|
|
108
|
+
|
|
109
|
+
- ⚙️ **`ckeditor5-dev-ci-trigger-circle-build`**
|
|
110
|
+
|
|
111
|
+
Triggers a **new CircleCI pipeline** for a specified repository.
|
|
112
|
+
Commonly used to initiate release or follow-up pipelines from an existing workflow.
|
|
113
|
+
|
|
114
|
+
**Environment variables:**
|
|
115
|
+
- `CKE5_CIRCLE_TOKEN` — CircleCI API token used for authentication.
|
|
116
|
+
|
|
117
|
+
**CircleCI-provided variables:**
|
|
118
|
+
- `CIRCLE_BRANCH` — Git branch of the currently processed pipeline.
|
|
119
|
+
- `CIRCLE_SHA1` — Full commit SHA of the currently processed pipeline.
|
|
120
|
+
|
|
121
|
+
**Parameters:**
|
|
122
|
+
- `--slug` — Repository slug (`org/name`) where the new pipeline will be started.
|
|
123
|
+
- `--trigger-repository-slug` — *(Optional)* Repository slug (`org/name`) that triggered the new pipeline.
|
|
124
|
+
Can be omitted if it matches `--slug`.
|
|
125
|
+
- `--release-branch` — *(Optional)* Branch that leads the release process.
|
|
12
126
|
|
|
13
127
|
## Changelog
|
|
14
128
|
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* For licensing, see LICENSE.md.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
import { parseArgs } from 'util';
|
|
8
9
|
import circleUpdateAutoCancelBuilds from '../lib/circle-update-auto-cancel-builds.js';
|
|
9
10
|
|
|
10
11
|
/**
|
|
@@ -13,26 +14,33 @@ import circleUpdateAutoCancelBuilds from '../lib/circle-update-auto-cancel-build
|
|
|
13
14
|
* It's needed when triggering a release process via CI to avoid canceling the release workflow by pushing
|
|
14
15
|
* a new commit (the released one) that will trigger a new pipeline.
|
|
15
16
|
*
|
|
16
|
-
* In order to integrate the action in your pipeline, you need prepare a few environment variables:
|
|
17
|
+
* In order to integrate the action in your pipeline, you need prepare a few CLI or environment variables:
|
|
17
18
|
*
|
|
18
|
-
* - CKE5_CIRCLE_TOKEN - an authorization token to talk to CircleCI REST API.
|
|
19
|
-
* -
|
|
20
|
-
* -
|
|
19
|
+
* - `CKE5_CIRCLE_TOKEN` - an authorization token to talk to CircleCI REST API.
|
|
20
|
+
* - `--organization` - a GitHub organization.
|
|
21
|
+
* - `--repository` - a GitHub repository.
|
|
21
22
|
*
|
|
22
23
|
* Example usage:
|
|
23
|
-
* CKE5_CIRCLE_TOKEN=... ckeditor5-dev-ci-circle-disable-auto-cancel-builds
|
|
24
|
+
* CKE5_CIRCLE_TOKEN=... ckeditor5-dev-ci-circle-disable-auto-cancel-builds --organization ... --repository ...
|
|
24
25
|
*/
|
|
25
26
|
|
|
26
|
-
const {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
const { values: cliOptions } = parseArgs( {
|
|
28
|
+
options: {
|
|
29
|
+
organization: {
|
|
30
|
+
type: 'string',
|
|
31
|
+
default: process.env.CKE5_GITHUB_ORGANIZATION
|
|
32
|
+
},
|
|
33
|
+
repository: {
|
|
34
|
+
type: 'string',
|
|
35
|
+
default: process.env.CKE5_GITHUB_REPOSITORY
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
} );
|
|
31
39
|
|
|
32
40
|
const options = {
|
|
33
|
-
circleToken: CKE5_CIRCLE_TOKEN,
|
|
34
|
-
githubOrganization:
|
|
35
|
-
githubRepository:
|
|
41
|
+
circleToken: process.env.CKE5_CIRCLE_TOKEN,
|
|
42
|
+
githubOrganization: cliOptions.organization,
|
|
43
|
+
githubRepository: cliOptions.repository,
|
|
36
44
|
newValue: false
|
|
37
45
|
};
|
|
38
46
|
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* For licensing, see LICENSE.md.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
import { parseArgs } from 'util';
|
|
8
9
|
import circleUpdateAutoCancelBuilds from '../lib/circle-update-auto-cancel-builds.js';
|
|
9
10
|
|
|
10
11
|
/**
|
|
@@ -13,26 +14,33 @@ import circleUpdateAutoCancelBuilds from '../lib/circle-update-auto-cancel-build
|
|
|
13
14
|
* It should be done only if a release workflow uses the `ckeditor5-dev-ci-circle-disable-auto-cancel-builds`
|
|
14
15
|
* script to disable the same option.
|
|
15
16
|
*
|
|
16
|
-
* In order to integrate the action in your pipeline, you need prepare a few environment variables:
|
|
17
|
+
* In order to integrate the action in your pipeline, you need prepare a few CLI or environment variables:
|
|
17
18
|
*
|
|
18
|
-
* - CKE5_CIRCLE_TOKEN - an authorization token to talk to CircleCI REST API.
|
|
19
|
-
* -
|
|
20
|
-
* -
|
|
19
|
+
* - `CKE5_CIRCLE_TOKEN` - an authorization token to talk to CircleCI REST API.
|
|
20
|
+
* - `--organization` - a GitHub organization.
|
|
21
|
+
* - `--repository` - a GitHub repository.
|
|
21
22
|
*
|
|
22
23
|
* Example usage:
|
|
23
|
-
* CKE5_CIRCLE_TOKEN=... ckeditor5-dev-ci-circle-enable-auto-cancel-builds
|
|
24
|
+
* CKE5_CIRCLE_TOKEN=... ckeditor5-dev-ci-circle-enable-auto-cancel-builds --organization ... --repository ...
|
|
24
25
|
*/
|
|
25
26
|
|
|
26
|
-
const {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
const { values: cliOptions } = parseArgs( {
|
|
28
|
+
options: {
|
|
29
|
+
organization: {
|
|
30
|
+
type: 'string',
|
|
31
|
+
default: process.env.CKE5_GITHUB_ORGANIZATION
|
|
32
|
+
},
|
|
33
|
+
repository: {
|
|
34
|
+
type: 'string',
|
|
35
|
+
default: process.env.CKE5_GITHUB_REPOSITORY
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
} );
|
|
31
39
|
|
|
32
40
|
const options = {
|
|
33
|
-
circleToken: CKE5_CIRCLE_TOKEN,
|
|
34
|
-
githubOrganization:
|
|
35
|
-
githubRepository:
|
|
41
|
+
circleToken: process.env.CKE5_CIRCLE_TOKEN,
|
|
42
|
+
githubOrganization: cliOptions.organization,
|
|
43
|
+
githubRepository: cliOptions.repository,
|
|
36
44
|
newValue: true
|
|
37
45
|
};
|
|
38
46
|
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* For licensing, see LICENSE.md.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
import { parseArgs } from 'util';
|
|
8
9
|
import { execSync } from 'child_process';
|
|
9
|
-
import minimist from 'minimist';
|
|
10
10
|
import processJobStatuses from '../lib/process-job-statuses.js';
|
|
11
11
|
import isWorkflowFinished from '../lib/utils/is-workflow-finished.js';
|
|
12
12
|
|
|
@@ -35,7 +35,7 @@ import isWorkflowFinished from '../lib/utils/is-workflow-finished.js';
|
|
|
35
35
|
// See: https://github.com/ckeditor/ckeditor5/issues/16403.
|
|
36
36
|
//
|
|
37
37
|
// By defining the `--ignore` option, you can skip waiting for particular jobs.
|
|
38
|
-
// You can also specify jobs to ignore
|
|
38
|
+
// You can also specify jobs to ignore.
|
|
39
39
|
//
|
|
40
40
|
// Let's consider the example below:
|
|
41
41
|
// ┌─────┐ ┌─────┐
|
|
@@ -54,7 +54,7 @@ import isWorkflowFinished from '../lib/utils/is-workflow-finished.js';
|
|
|
54
54
|
// The assumption is that "Job D" is the approval job. To ignore it and its children, you can execute
|
|
55
55
|
// the notifier like this:
|
|
56
56
|
//
|
|
57
|
-
// $ ckeditor5-dev-ci-circle-workflow-notifier --ignore
|
|
57
|
+
// $ ckeditor5-dev-ci-circle-workflow-notifier --ignore="Job D" --ignore="Job E"
|
|
58
58
|
|
|
59
59
|
const {
|
|
60
60
|
/**
|
|
@@ -67,7 +67,19 @@ const {
|
|
|
67
67
|
CIRCLE_JOB
|
|
68
68
|
} = process.env;
|
|
69
69
|
|
|
70
|
-
const { task, ignore } =
|
|
70
|
+
const { values: { task, ignore } } = parseArgs( {
|
|
71
|
+
options: {
|
|
72
|
+
task: {
|
|
73
|
+
type: 'string',
|
|
74
|
+
default: 'pnpm ckeditor5-dev-ci-notify-circle-status'
|
|
75
|
+
},
|
|
76
|
+
ignore: {
|
|
77
|
+
type: 'string',
|
|
78
|
+
multiple: true,
|
|
79
|
+
default: []
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
} );
|
|
71
83
|
|
|
72
84
|
waitForOtherJobsAndSendNotification()
|
|
73
85
|
.catch( err => {
|
|
@@ -113,33 +125,3 @@ async function getOtherJobsData() {
|
|
|
113
125
|
|
|
114
126
|
return data.items.filter( job => job.name !== CIRCLE_JOB );
|
|
115
127
|
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* @param {Array.<string>} args
|
|
119
|
-
* @returns {object} result
|
|
120
|
-
* @returns {string} result.task
|
|
121
|
-
* @returns {Array.<string>} result.ignore
|
|
122
|
-
*/
|
|
123
|
-
function parseArguments( args ) {
|
|
124
|
-
const config = {
|
|
125
|
-
string: [
|
|
126
|
-
'task',
|
|
127
|
-
'ignore'
|
|
128
|
-
],
|
|
129
|
-
|
|
130
|
-
default: {
|
|
131
|
-
task: 'pnpm ckeditor5-dev-ci-notify-circle-status',
|
|
132
|
-
ignore: []
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
let { task, ignore } = minimist( args, config );
|
|
137
|
-
|
|
138
|
-
if ( typeof ignore === 'string' ) {
|
|
139
|
-
ignore = [ ignore ];
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
ignore = ignore.flatMap( item => item.split( ',' ) );
|
|
143
|
-
|
|
144
|
-
return { task, ignore };
|
|
145
|
-
}
|
|
@@ -5,40 +5,49 @@
|
|
|
5
5
|
* For licensing, see LICENSE.md.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
import { parseArgs } from 'util';
|
|
8
9
|
import isJobTriggeredByMember from '../lib/is-job-triggered-by-member.js';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* This script checks if a user that approved an approval job could do that.
|
|
12
13
|
*
|
|
13
|
-
* In order to integrate the action in your pipeline, you need prepare a few environment variables:
|
|
14
|
+
* In order to integrate the action in your pipeline, you need prepare a few CLI or environment variables:
|
|
14
15
|
*
|
|
15
|
-
* - CIRCLE_WORKFLOW_ID - provided by default by CircleCI and keeps a unique id of the CI build.
|
|
16
|
-
* - CKE5_CIRCLE_TOKEN - an authorization token to talk to CircleCI REST API.
|
|
17
|
-
* -
|
|
18
|
-
* -
|
|
19
|
-
* -
|
|
20
|
-
*
|
|
16
|
+
* - `CIRCLE_WORKFLOW_ID` - provided by default by CircleCI and keeps a unique id of the CI build.
|
|
17
|
+
* - `CKE5_CIRCLE_TOKEN` - an authorization token to talk to CircleCI REST API.
|
|
18
|
+
* - `CKE5_GITHUB_TOKEN` - a GitHub token used for authorization a request.
|
|
19
|
+
* - `--team` - a GitHub team name (slug) that defines accounts that could approve the job.
|
|
20
|
+
* - `--organization` - your GitHub organization.
|
|
21
|
+
* - `--job` - a job name to verify.
|
|
21
22
|
*
|
|
22
23
|
* Example usage:
|
|
23
24
|
* CKE5_CIRCLE_TOKEN=... ckeditor5-dev-ci-is-job-triggered-by-member
|
|
24
25
|
*/
|
|
25
26
|
|
|
26
|
-
const {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
27
|
+
const { values: cliOptions } = parseArgs( {
|
|
28
|
+
options: {
|
|
29
|
+
job: {
|
|
30
|
+
type: 'string',
|
|
31
|
+
default: process.env.CKE5_CIRCLE_APPROVAL_JOB_NAME
|
|
32
|
+
},
|
|
33
|
+
organization: {
|
|
34
|
+
type: 'string',
|
|
35
|
+
default: process.env.CKE5_GITHUB_ORGANIZATION
|
|
36
|
+
},
|
|
37
|
+
team: {
|
|
38
|
+
type: 'string',
|
|
39
|
+
default: process.env.CKE5_GITHUB_TEAM_SLUG
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
} );
|
|
34
43
|
|
|
35
44
|
const options = {
|
|
36
|
-
circleToken: CKE5_CIRCLE_TOKEN,
|
|
37
|
-
circleWorkflowId: CIRCLE_WORKFLOW_ID,
|
|
38
|
-
circleApprovalJobName:
|
|
39
|
-
githubOrganization:
|
|
40
|
-
githubTeamSlug:
|
|
41
|
-
githubToken: CKE5_GITHUB_TOKEN
|
|
45
|
+
circleToken: process.env.CKE5_CIRCLE_TOKEN,
|
|
46
|
+
circleWorkflowId: process.env.CIRCLE_WORKFLOW_ID,
|
|
47
|
+
circleApprovalJobName: cliOptions.job,
|
|
48
|
+
githubOrganization: cliOptions.organization,
|
|
49
|
+
githubTeamSlug: cliOptions.team,
|
|
50
|
+
githubToken: process.env.CKE5_GITHUB_TOKEN
|
|
42
51
|
};
|
|
43
52
|
|
|
44
53
|
isJobTriggeredByMember( options )
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* For licensing, see LICENSE.md.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
import { parseArgs } from 'util';
|
|
8
9
|
import slackNotify from 'slack-notify';
|
|
9
10
|
import formatMessage from '../lib/format-message.js';
|
|
10
11
|
|
|
@@ -14,11 +15,6 @@ import formatMessage from '../lib/format-message.js';
|
|
|
14
15
|
// Described environment variables starting with "CKE5" should be added by the integrator.
|
|
15
16
|
|
|
16
17
|
const {
|
|
17
|
-
/**
|
|
18
|
-
* Required. Value of Circle's `pipeline.number` variable.
|
|
19
|
-
*/
|
|
20
|
-
CKE5_PIPELINE_NUMBER,
|
|
21
|
-
|
|
22
18
|
/**
|
|
23
19
|
* Required. Token to a Github account with the scope: "repos". It is required for obtaining an author of
|
|
24
20
|
* the commit if the build failed. The repository can be private and we can't use the public API.
|
|
@@ -35,28 +31,49 @@ const {
|
|
|
35
31
|
*/
|
|
36
32
|
CKE5_SLACK_WEBHOOK_URL,
|
|
37
33
|
|
|
38
|
-
/**
|
|
39
|
-
* Optional. If both are defined, the script will use the URL as the commit URL.
|
|
40
|
-
* Otherwise, URL will be constructed using current repository data.
|
|
41
|
-
*/
|
|
42
|
-
CKE5_TRIGGER_REPOSITORY_SLUG,
|
|
43
|
-
CKE5_TRIGGER_COMMIT_HASH,
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Optional. If set to "true", commit author will be hidden.
|
|
47
|
-
* See: https://github.com/ckeditor/ckeditor5/issues/9252.
|
|
48
|
-
*/
|
|
49
|
-
CKE5_SLACK_NOTIFY_HIDE_AUTHOR,
|
|
50
|
-
|
|
51
34
|
// Variables that are available by default in Circle environment.
|
|
52
35
|
CIRCLE_BRANCH,
|
|
53
|
-
CIRCLE_BUILD_NUM,
|
|
54
36
|
CIRCLE_PROJECT_REPONAME,
|
|
55
37
|
CIRCLE_PROJECT_USERNAME,
|
|
56
38
|
CIRCLE_SHA1,
|
|
57
39
|
CIRCLE_WORKFLOW_ID
|
|
58
40
|
} = process.env;
|
|
59
41
|
|
|
42
|
+
const { values: cliArguments } = parseArgs( {
|
|
43
|
+
options: {
|
|
44
|
+
/**
|
|
45
|
+
* Required. Value of Circle's `pipeline.number` variable.
|
|
46
|
+
* Unfortunately, it does not overlap with `CIRCLE_BUILD_NUM`.
|
|
47
|
+
*/
|
|
48
|
+
'pipeline-id': {
|
|
49
|
+
type: 'string',
|
|
50
|
+
default: process.env.CKE5_PIPELINE_NUMBER
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Optional. If both are defined, the script will use the URL as the commit URL.
|
|
55
|
+
* Otherwise, URL will be constructed using the current repository data.
|
|
56
|
+
*/
|
|
57
|
+
'trigger-repository-slug': {
|
|
58
|
+
type: 'string',
|
|
59
|
+
default: process.env.CKE5_TRIGGER_REPOSITORY_SLUG
|
|
60
|
+
},
|
|
61
|
+
'trigger-commit-hash': {
|
|
62
|
+
type: 'string',
|
|
63
|
+
default: process.env.CKE5_TRIGGER_COMMIT_HASH
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Optional. If set to "true" or "1", commit author will be hidden.
|
|
68
|
+
* See: https://github.com/ckeditor/ckeditor5/issues/9252.
|
|
69
|
+
*/
|
|
70
|
+
'hide-author': {
|
|
71
|
+
type: 'string',
|
|
72
|
+
default: process.env.CKE5_SLACK_NOTIFY_HIDE_AUTHOR
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
} );
|
|
76
|
+
|
|
60
77
|
notifyCircleStatus();
|
|
61
78
|
|
|
62
79
|
async function notifyCircleStatus() {
|
|
@@ -68,12 +85,16 @@ async function notifyCircleStatus() {
|
|
|
68
85
|
throw new Error( 'Missing environment variable: CKE5_SLACK_WEBHOOK_URL' );
|
|
69
86
|
}
|
|
70
87
|
|
|
88
|
+
if ( !CKE5_CIRCLE_TOKEN ) {
|
|
89
|
+
throw new Error( 'Missing environment variable: CKE5_CIRCLE_TOKEN' );
|
|
90
|
+
}
|
|
91
|
+
|
|
71
92
|
const jobData = await getJobData();
|
|
72
93
|
const buildUrl = [
|
|
73
94
|
'https://app.circleci.com/pipelines/github',
|
|
74
95
|
CIRCLE_PROJECT_USERNAME,
|
|
75
96
|
CIRCLE_PROJECT_REPONAME,
|
|
76
|
-
|
|
97
|
+
cliArguments[ 'pipeline-id' ],
|
|
77
98
|
'workflows',
|
|
78
99
|
CIRCLE_WORKFLOW_ID
|
|
79
100
|
].join( '/' );
|
|
@@ -91,7 +112,7 @@ async function notifyCircleStatus() {
|
|
|
91
112
|
triggeringCommitUrl: getTriggeringCommitUrl(),
|
|
92
113
|
startTime: Math.ceil( ( new Date( jobData.started_at ) ).getTime() / 1000 ),
|
|
93
114
|
endTime: Math.ceil( ( new Date() ) / 1000 ),
|
|
94
|
-
shouldHideAuthor:
|
|
115
|
+
shouldHideAuthor: isTrueLike( cliArguments[ 'hide-author' ] )
|
|
95
116
|
} );
|
|
96
117
|
|
|
97
118
|
return slackNotify( CKE5_SLACK_WEBHOOK_URL )
|
|
@@ -105,7 +126,7 @@ async function getJobData() {
|
|
|
105
126
|
CIRCLE_PROJECT_USERNAME,
|
|
106
127
|
CIRCLE_PROJECT_REPONAME,
|
|
107
128
|
'job',
|
|
108
|
-
|
|
129
|
+
cliArguments[ 'pipeline-id' ]
|
|
109
130
|
].join( '/' );
|
|
110
131
|
|
|
111
132
|
const fetchOptions = {
|
|
@@ -120,9 +141,12 @@ async function getJobData() {
|
|
|
120
141
|
function getTriggeringCommitUrl() {
|
|
121
142
|
let repoSlug, hash;
|
|
122
143
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
144
|
+
const cliRepoSlug = cliArguments[ 'trigger-repository-slug' ];
|
|
145
|
+
const cliCommitHash = cliArguments[ 'trigger-commit-hash' ];
|
|
146
|
+
|
|
147
|
+
if ( cliRepoSlug && cliCommitHash ) {
|
|
148
|
+
repoSlug = cliRepoSlug.trim();
|
|
149
|
+
hash = cliCommitHash.trim();
|
|
126
150
|
} else {
|
|
127
151
|
repoSlug = [ CIRCLE_PROJECT_USERNAME, CIRCLE_PROJECT_REPONAME ].join( '/' );
|
|
128
152
|
hash = CIRCLE_SHA1;
|
|
@@ -130,3 +154,7 @@ function getTriggeringCommitUrl() {
|
|
|
130
154
|
|
|
131
155
|
return [ 'https://github.com', repoSlug, 'commit', hash ].join( '/' );
|
|
132
156
|
}
|
|
157
|
+
|
|
158
|
+
function isTrueLike( value ) {
|
|
159
|
+
return value === true || value === 1 || value === '1' || value === 'true';
|
|
160
|
+
}
|
|
@@ -5,43 +5,53 @@
|
|
|
5
5
|
* For licensing, see LICENSE.md.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
import { parseArgs } from 'util';
|
|
8
9
|
import triggerCircleBuild from '../lib/trigger-circle-build.js';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* This script triggers a new CircleCI build.
|
|
12
13
|
*
|
|
13
|
-
* In order to integrate the action in your pipeline, you need prepare a few environment variables:
|
|
14
|
+
* In order to integrate the action in your pipeline, you need prepare a few CLI or environment variables:
|
|
14
15
|
*
|
|
15
|
-
* - CIRCLE_BRANCH - provided by default by CircleCI and keeps the git branch of processed
|
|
16
|
-
* -
|
|
17
|
-
* - CKE5_CIRCLE_TOKEN - an authorization token to talk to CircleCI REST API.
|
|
18
|
-
* -
|
|
19
|
-
* -
|
|
20
|
-
*
|
|
16
|
+
* - `CIRCLE_BRANCH` - provided by default by CircleCI and keeps the git branch of processed pipeline.
|
|
17
|
+
* - `CIRCLE_SHA1` - provided by default by CircleCI and keeps a full commit identifier of the processed the pipeline.
|
|
18
|
+
* - `CKE5_CIRCLE_TOKEN` - an authorization token to talk to CircleCI REST API.
|
|
19
|
+
* - `--slug` - a repository slug (org/name) where a new pipeline will be started.
|
|
20
|
+
* - `--trigger-repository-slug` - (optional) a repository slug (org/name) that triggers a new pipeline.
|
|
21
|
+
* Can be skipped when overlaps with `--slug`.
|
|
22
|
+
* - `--release-branch` - (optional) define a branch that leads the release process.
|
|
21
23
|
*
|
|
22
24
|
* Example usage:
|
|
23
25
|
* CKE5_CIRCLE_TOKEN=... ckeditor5-dev-ci-trigger-circle-build
|
|
24
26
|
*/
|
|
25
27
|
|
|
26
|
-
const {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
const { values: cliOptions } = parseArgs( {
|
|
29
|
+
options: {
|
|
30
|
+
slug: {
|
|
31
|
+
type: 'string',
|
|
32
|
+
default: process.env.CKE5_GITHUB_REPOSITORY_SLUG
|
|
33
|
+
},
|
|
34
|
+
'trigger-repository-slug': {
|
|
35
|
+
type: 'string',
|
|
36
|
+
default: process.env.CKE5_GITHUB_TRIGGER_REPOSITORY_SLUG
|
|
37
|
+
},
|
|
38
|
+
'release-branch': {
|
|
39
|
+
type: 'string',
|
|
40
|
+
default: process.env.CKE5_GITHUB_RELEASE_BRANCH
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
} );
|
|
34
44
|
|
|
35
45
|
const options = {
|
|
36
|
-
circleToken: CKE5_CIRCLE_TOKEN,
|
|
37
|
-
commit:
|
|
38
|
-
branch: CIRCLE_BRANCH,
|
|
39
|
-
releaseBranch:
|
|
40
|
-
repositorySlug:
|
|
46
|
+
circleToken: process.env.CKE5_CIRCLE_TOKEN,
|
|
47
|
+
commit: process.env.CIRCLE_SHA1,
|
|
48
|
+
branch: process.env.CIRCLE_BRANCH,
|
|
49
|
+
releaseBranch: cliOptions[ 'release-branch' ],
|
|
50
|
+
repositorySlug: cliOptions.slug
|
|
41
51
|
};
|
|
42
52
|
|
|
43
|
-
if (
|
|
44
|
-
options.triggerRepositorySlug =
|
|
53
|
+
if ( cliOptions[ 'trigger-repository-slug' ] ) {
|
|
54
|
+
options.triggerRepositorySlug = cliOptions[ 'trigger-repository-slug' ];
|
|
45
55
|
}
|
|
46
56
|
|
|
47
57
|
triggerCircleBuild( options )
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckeditor/ckeditor5-dev-ci",
|
|
3
|
-
"version": "53.
|
|
3
|
+
"version": "53.4.0",
|
|
4
4
|
"description": "Utils used on various Continuous Integration services.",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "CKSource (http://cksource.com/)",
|
|
@@ -36,7 +36,6 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@octokit/rest": "^22.0.0",
|
|
39
|
-
"minimist": "^1.2.8",
|
|
40
39
|
"slack-notify": "^2.0.6"
|
|
41
40
|
}
|
|
42
41
|
}
|