Skip to content

Commit 911a0e7

Browse files
committed
fix: initial release
1 parent 433a04d commit 911a0e7

File tree

1 file changed

+98
-0
lines changed

1 file changed

+98
-0
lines changed

.gitlab-ci.yml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
---
2+
.configure-registry: &configure-registry
3+
- apk --quiet --no-progress --update --no-cache add git openssh
4+
- NODE_ENV=cicd yarn install --frozen-lockfile --cache-folder .npm --prefer-offline
5+
- |
6+
{
7+
echo "//registry.npmjs.com/:_authToken=${NPM_TOKEN}"
8+
echo "@cloudgraph:registry=https://registry.npmjs.com/"
9+
} | tee -a .npmrc
10+
- |
11+
{
12+
echo "\"@cloudgraph:registry\" \"https://registry.npmjs.com/\""
13+
echo "\"//registry.npmjs.com/:_authToken\" \"${NPM_TOKEN}\""
14+
} | tee -a .yarnrc
15+
default:
16+
image: node:16-alpine
17+
before_script:
18+
- *configure-registry
19+
cache:
20+
key: ${CI_COMMIT_REF_SLUG}
21+
paths:
22+
- .npm/
23+
- dist/
24+
25+
workflow:
26+
rules:
27+
- if: '$CI_PIPELINE_SOURCE == "push"'
28+
29+
variables:
30+
NPM_TOKEN: ${NPM_TOKEN}
31+
32+
stages:
33+
- build
34+
- test
35+
- publish
36+
- notify
37+
38+
build:
39+
image: node:16-alpine
40+
stage: build
41+
rules:
42+
- if: $CI_COMMIT_TAG
43+
when: never
44+
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_COMMIT_MESSAGE =~ /^chore\(release\)/'
45+
when: never
46+
- if: $CI_COMMIT_BRANCH
47+
when: always
48+
script:
49+
- yarn prepublish
50+
51+
# test:
52+
# image: node:16-alpine
53+
# stage: test
54+
# rules:
55+
# - when: always
56+
# script:
57+
# - yarn test
58+
59+
semantic release:
60+
image: node:16-alpine
61+
stage: publish
62+
rules:
63+
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_COMMIT_MESSAGE =~ /^chore\(release\)/'
64+
when: never
65+
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
66+
variables:
67+
# Set git commit identity
68+
GIT_AUTHOR_NAME: "AutoCloud Deploy Bot"
69+
GIT_AUTHOR_EMAIL: "[email protected]"
70+
GIT_COMMITTER_NAME: "AutoCloud Deploy Bot"
71+
GIT_COMMITTER_EMAIL: "[email protected]"
72+
# Disable Husky for the git step of semantic release (handles all versions, env var name changed in v6)
73+
HUSKY_SKIP_HOOKS: 1
74+
HUSKY: 0
75+
before_script:
76+
- *configure-registry
77+
script:
78+
- npx semantic-release -r $CI_PROJECT_URL
79+
80+
.curlcmd: &curlcmd >
81+
curl
82+
-sS
83+
-X POST
84+
--data-urlencode "payload={\"attachments\":[{\"fallback\":\"$GITLAB_USER_NAME released new $CI_PROJECT_TITLE version $CI_COMMIT_TAG\",\"color\":\"good\",\"author_name\":\"$GITLAB_USER_NAME ($GITLAB_USER_LOGIN)\",\"author_icon\":\"$GITLAB_USER_AVATAR\",\"author_link\":\"https://gitlab.com/$GITLAB_USER_LOGIN\",\"title\":\"Version $CI_COMMIT_TAG of $CI_PROJECT_NAME released\",\"title_link\":\"$CI_PROJECT_URL/-/tags/$CI_COMMIT_TAG\",\"fields\":[{\"title\":\"Tag\",\"value\":\"<$CI_PROJECT_URL/commits/$CI_COMMIT_TAG|$CI_COMMIT_TAG>\",\"short\":true},{\"title\":\"Commit\",\"value\":\"<$CI_PROJECT_URL/tree/$CI_COMMIT_SHA|$CI_COMMIT_TITLE>\",\"short\":true}],\"footer\":\"$CI_PROJECT_NAME\",\"ts\":$( date +%s )}]}"
85+
$SLACK_API_ENDPOINT
86+
87+
notify:
88+
image: alpine:latest
89+
stage: notify
90+
rules:
91+
- if: $CI_COMMIT_TAG
92+
# Overwrite the default before script with a no-op action to disable the node specific actions
93+
before_script:
94+
- echo "noop"
95+
script:
96+
- apk add --no-cache curl
97+
- GITLAB_USER_AVATAR=$( echo $GITLAB_USER_EMAIL | tr '[:upper:]' '[:lower:]' | tr -d '[:space:]' | md5sum | awk -F' ' '{print $1}' | xargs -I{} echo 'https://www.gravatar.com/avatar/{}?s=80&d=identicon' )
98+
- *curlcmd

0 commit comments

Comments
 (0)