11---
2+ .install-packages : &install-packages
3+ - apk --quiet --no-progress --update --no-cache add git openssh curl
4+ - ln -s /usr/bin/sha256sum /usr/bin/shasum
5+
26.configure-registry : &configure-registry
3- - apk --quiet --no-progress --update --no-cache add git openssh
47 - |
58 {
69 echo "//registry.npmjs.com/:_authToken=${NPM_TOKEN}"
1215 echo "\"//registry.npmjs.com/:_authToken\" \"${NPM_TOKEN}\""
1316 } | tee -a .yarnrc
1417 - NODE_ENV=cicd yarn install --frozen-lockfile --cache-folder .npm --prefer-offline
18+
19+ .configure-ssh : &configure-ssh
20+ - mkdir -p ~/.ssh
21+ - chmod 700 ~/.ssh
22+ - echo "$GITHUB_SSH_KEY" | tr -d '\r' > ~/.ssh/github_autodeploy
23+ - chmod 600 ~/.ssh/github_autodeploy
24+ - |
25+ {
26+ echo "Host github.com"
27+ echo "HostName github.com"
28+ echo "User git"
29+ echo "PreferredAuthentications publickey"
30+ echo "Port 22"
31+ echo "TCPKeepAlive yes"
32+ echo "IdentitiesOnly yes"
33+ echo "AddKeysToAgent yes"
34+ echo "IdentityFile ~/.ssh/github_autodeploy"
35+ echo "StrictHostKeyChecking no"
36+ } | tee -a /root/.ssh/config
37+ - chmod 0600 /root/.ssh/config
38+
1539default :
1640 image : node:16-alpine
1741 before_script :
42+ - *install-packages
1843 - *configure-registry
1944 cache :
2045 key : ${CI_COMMIT_REF_SLUG}
@@ -37,7 +62,6 @@ stages:
3762 - notify
3863
3964build :
40- image : node:16-alpine
4165 stage : build
4266 rules :
4367 - if : $CI_COMMIT_TAG
5074 - yarn prepack
5175
5276lint :
53- image : node:16-alpine
5477 stage : test
5578 rules :
5679 - when : always
6689# - yarn test
6790
6891semantic release :
69- image : node:16-alpine
7092 stage : release
7193 rules :
7294 - if : ' $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_COMMIT_MESSAGE =~ /^chore\(release\)/'
@@ -83,10 +105,53 @@ semantic release:
83105 # Disable Husky for the git step of semantic release (handles all versions, env var name changed in v6)
84106 HUSKY_SKIP_HOOKS : 1
85107 HUSKY : 0
108+ script :
109+ - npx semantic-release -r $CI_PROJECT_URL
110+
111+ homebrew :
112+ image : node:16
113+ stage : release
114+ rules :
115+ - if : $CI_COMMIT_BRANCH
116+ when : never
117+ - if : $CI_COMMIT_TAG =~ /alpha/
118+ when : never
119+ - if : $CI_COMMIT_TAG =~ /beta/
120+ when : never
121+ - if : $CI_COMMIT_TAG
122+ when : always
123+ variables :
124+ # Set git commit identity
125+ GIT_AUTHOR_NAME : ' AutoCloud Deploy Bot'
126+ GIT_AUTHOR_EMAIL : ' no-reply@loudcloud.dev'
127+ GIT_COMMITTER_NAME : ' AutoCloud Deploy Bot'
128+ GIT_COMMITTER_EMAIL : ' no-reply@loudcloud.dev'
86129 before_script :
130+ # - *install-packages
87131 - *configure-registry
132+ - *configure-ssh
133+ - mkdir -p /root/.aws
134+ - |
135+ cat << EOF > /root/.aws/config
136+ [default]
137+ region=us-east-1
138+ output=json
139+
140+ [profile autocloud-iac]
141+ role_arn = ${AWS_ROLE_ARN}
142+ source_profile = default
143+ EOF
144+ - |
145+ cat << EOF > /root/.aws/credentials
146+ [default]
147+ aws_access_key_id = ${AWS_ACCESS_KEY_ID}
148+ aws_secret_access_key = ${AWS_SECRET_ACCESS_KEY}
149+ EOF
150+ - export AWS_SDK_LOAD_CONFIG=true
151+ - export AWS_PROFILE=autocloud-iac
88152 script :
89- - npx semantic-release -r $CI_PROJECT_URL
153+ - yarn build
154+ - yarn homebrew
90155
91156.curlcmd : &curlcmd >
92157 curl
@@ -96,7 +161,6 @@ semantic release:
96161 $SLACK_API_ENDPOINT
97162
98163notify :
99- image : alpine:latest
100164 stage : notify
101165 rules :
102166 - if : $CI_COMMIT_TAG
0 commit comments