Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitea68d54

Browse files
authored
Merge pull request#27 from streamich/commit-7
first 7 chars of commit SHA1
2 parentsef52a55 +4709f0d commitea68d54

File tree

4 files changed

+28
-33
lines changed

4 files changed

+28
-33
lines changed

‎README.md‎

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,14 @@
22

33
`cross-ci` standardizes environment variables for CI. For example,
44
your can simply use`BUILD_BRANCH` variable in all CI runners instead of`CIRCLE_BRANCH` in
5-
CircleCI or`TRAVIS_PULL_REQUEST_BRANCH` in Travis. Supports[all`env-ci` implemented services](https://github.com/pvdlg/env-ci#supported-ci).
5+
CircleCI or`TRAVIS_PULL_REQUEST_BRANCH` in Travis.
66

77
#####Install
88

99
```
1010
npm i cross-ci
1111
```
1212

13-
#####Install Globally
14-
15-
```
16-
npm i -g cross-ci
17-
```
18-
1913
#####Node usage
2014

2115
```js
@@ -25,7 +19,7 @@ const vars = require('cross-ci').vars;
2519
#####CLI usage
2620

2721
```
28-
cross-ci printenv BUILD_COMMIT_URL
22+
npxcross-ci printenv BUILD_COMMIT_URL
2923
```
3024

3125
##Variables
@@ -34,6 +28,7 @@ cross-ci printenv BUILD_COMMIT_URL
3428
-[`BUILD_COMMIT_PR_URL`](#build_commit_pr_url)
3529
-[`BUILD_COMMIT_URL`](#build_commit_url)
3630
-[`BUILD_COMMIT`](#build_commit)
31+
-[`BUILD_COMMIT7`](#build_commit7)
3732
-[`BUILD_DIR`](#build_dir)
3833
-[`BUILD_NUM`](#build_num)
3934
-[`BUILD_PR_NUM`](#build_pr_num)
@@ -69,13 +64,13 @@ cross-ci printenv BUILD_COMMIT_URL
6964
#####`:echo`
7065

7166
```shell
72-
cross-ci :echo node --eval"\"console.log('\${PROJECT_NAME}')\""
67+
npxcross-ci :echo node --eval"\"console.log('\${PROJECT_NAME}')\""
7368
```
7469

7570
#####`:run`
7671

7772
```shell
78-
cross-ci :run node --eval"\"console.log('\${PROJECT_NAME}')\""
73+
npxcross-ci :run node --eval"\"console.log('\${PROJECT_NAME}')\""
7974
```
8075

8176
##Examples
@@ -93,14 +88,14 @@ cross-ci :run node --eval "\"console.log('\${PROJECT_NAME}')\""
9388
#####Update GitHub status
9489

9590
```shell
96-
cross-ci :run \
91+
npxcross-ci :run \
9792
npx commit-status success Storybook"'\${BUILD_VERSION}'""'https://example.com'"
9893
```
9994

10095
#####Upload to S3
10196

10297
```shell
103-
cross-ci :run \
98+
npxcross-ci :run \
10499
s3 sync ./public"s3://bucket/builds/\${PROJECT_NAME}/\${BUILD_VERSION}/public" \
105100
--region eu-west-1 \
106101
--acl public-read
@@ -109,7 +104,7 @@ cross-ci :run \
109104
#####Post to Slack
110105

111106
```shell
112-
cross-ci :run \
107+
npxcross-ci :run \
113108
curl -X POST -H'Content-type: application/json' \
114109
--data"'{\
115110
\"text\":\"Built\\\`<\${PROJECT_URL}|\${PROJECT_NAME}>\\\` :crossed_fingers:\\\`<\${BRANCH_URL}|\${BUILD_BRANCH}>\\\` :crossed_fingers:\\\`\${BUILD_VERSION}\\\` on <\${BUILD_URL}|\${CI_NAME}> :tada:\",\
@@ -122,20 +117,12 @@ cross-ci :run \
122117

123118
```shell
124119
GITHUB_TOKEN=XXXXXXXX \
125-
cross-ci :run \
120+
npxcross-ci :run \
126121
curl -X POST -H"Content-Type: application/json" \
127122
--data"'{\"body\":\"Build version:\\\`\${BUILD_VERSION}\\\` :crossed_fingers: [\\\`\${BUILD_BRANCH}\\\`](\${BRANCH_URL}) on [\${CI_NAME}](\${BUILD_URL}) :tada:\"}'" \
128123
"https://api.github.com/repos/\${PROJECT_OWNER}/\${PROJECT_NAME}/issues/\${BUILD_PR_NUM}/comments?access_token=\${GITHUB_TOKEN}"
129124
```
130125

131-
#####Display all env vars and save to`buildinfo.json`
132-
133-
```shell
134-
cross-ci
135-
cross-ci> buildinfo.json
136-
```
137-
138-
139126
##Variable Reference
140127

141128

@@ -168,6 +155,14 @@ SHA1 of the Git commit being built.
168155

169156

170157

158+
####`BUILD_COMMIT7`
159+
160+
161+
162+
First 7 chars of SHA1 of the Git commit being built.
163+
164+
165+
171166
####`BUILD_DIR`
172167

173168

‎lib/createVars.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const list = [
2121
'BUILD_PR_NUM',
2222
'BUILD_URL',
2323
'BUILD_COMMIT',
24+
'BUILD_COMMIT7',
2425
'BUILD_COMMIT_URL',
2526
'BUILD_COMMIT_PR_URL',
2627
'BUILD_PR_URL',

‎lib/var/BUILD_COMMIT7.js‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
constBUILD_COMMIT=require('./BUILD_COMMIT');
2+
3+
/// First 7 chars of SHA1 of the Git commit being built.
4+
constBUILD_COMMIT7=()=>
5+
(BUILD_COMMIT()||'').slice(0,7);
6+
7+
module.exports=BUILD_COMMIT7;

‎package.json‎

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@
1212
"build":"npm run build:readme",
1313
"build:readme":"mmarkdown --src ./build/readme.md --out README.md --scripts ./build/mmd.js",
1414
"test":"jest",
15-
"eslint":"eslint --ignore-path .gitignore './**/*.js'",
16-
"precommit":"npm run eslint",
17-
"prepush":"npm t"
15+
"eslint":"eslint --ignore-path .gitignore './**/*.js'"
1816
},
1917
"dependencies": {
2018
"env-ci":"^2.1.0"
@@ -25,8 +23,7 @@
2523
"eslint":"4.19.1",
2624
"eslint-config-mailonline":"9.0.0",
2725
"mol-conventional-changelog":"1.2.0",
28-
"jest":"22.4.3",
29-
"jest-tap-reporter":"1.9.0",
26+
"jest":"29.5.0",
3027
"husky":"0.14.3"
3128
},
3229
"config": {
@@ -46,10 +43,5 @@
4643
"circle",
4744
"travisci",
4845
"circleci"
49-
],
50-
"jest": {
51-
"reporters": [
52-
"jest-tap-reporter"
53-
]
54-
}
46+
]
5547
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp