Skip to content

Commit d90220e

Browse files
authored
chore(ci): Create docker images for commits in cd/staging (#1090)
* chore(ci): Trigger docker build for branch cd/staging * chore(ci): Cleanup unused jobs * chore(ci): Add timestamp to image tag to order for latest * fix(ci): Stricter token matching on cd/staging
1 parent 8d3c4b7 commit d90220e

File tree

1 file changed

+10
-66
lines changed

1 file changed

+10
-66
lines changed

.circleci/config.yml

Lines changed: 10 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -35,40 +35,6 @@ commands:
3535
- run: git submodule sync
3636
- run: sudo apt-get install gcc libc-dev
3737
- run: git submodule update --init
38-
trigger-deployment:
39-
steps:
40-
- checkout
41-
- run:
42-
name: Trigger deployment for filecoin-project/lily
43-
command: |
44-
# derive docker image deploy-tag according to the publish-* steps in this config
45-
branch_tag_suffix=`echo "$CIRCLE_SHA1" | cut -c 1-8`
46-
sanitized_branch=`echo $CIRCLE_BRANCH | sed 's:/:-:g'`
47-
deploy_branch=${sanitized_branch}-${branch_tag_suffix}
48-
sanitized_tag=`echo $CIRCLE_TAG | sed 's:/:-:g'`
49-
50-
# if $sanitized_tag is empty, default to $sanitized_branch
51-
deploy_target=${sanitized_tag:-$deploy_branch}
52-
53-
# curlf fails with a non-zero exit code when the status code is not 2XX
54-
curlf() {
55-
OUTPUT_FILE=$(mktemp)
56-
HTTP_CODE=$(curl --silent --output $OUTPUT_FILE --write-out "%{http_code}" "$@")
57-
if [[ ${HTTP_CODE} -lt 200 || ${HTTP_CODE} -gt 299 ]] ; then
58-
>&2 cat $OUTPUT_FILE
59-
return 22
60-
fi
61-
cat $OUTPUT_FILE
62-
rm $OUTPUT_FILE
63-
}
64-
65-
# trigger deployment in sentinel-infra repo
66-
curlf --request POST \
67-
--url https://circleci.com/api/v2/project/gh/filecoin-project/sentinel-infra/pipeline \
68-
--header "Circle-Token: $SENTINEL_INFRA_CIRCLECI_API_TOKEN" \
69-
--header "content-type: application/json" \
70-
--data "{\"branch\":\"master\",\"parameters\":{\"trigger-deploy\": true, \"deploy-tag\":\"$deploy_target\"}}"
71-
echo ""
7238
validate-docker-executeable:
7339
steps:
7440
- run:
@@ -89,7 +55,8 @@ jobs:
8955
echo "$DOCKERHUB_PASS" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin
9056
sanitized_branch=`echo $CIRCLE_BRANCH | sed 's:/:-:g'`
9157
tag_suffix=$(echo "$CIRCLE_SHA1" | cut -c 1-8)
92-
make docker-mainnet-push LILY_IMAGE_TAG=${sanitized_branch}-${tag_suffix}
58+
tag_date=$(date +%Y%m%d%H%M)
59+
make docker-mainnet-push LILY_IMAGE_TAG=${sanitized_branch}-${tag_date}-${tag_suffix}
9360
publish-production-image-from-branch-for-calibnet:
9461
executor: dockerizer
9562
steps:
@@ -170,16 +137,6 @@ jobs:
170137
if [[ "$CIRCLE_TAG" =~ ^(v[0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
171138
LILY_IMAGE_TAG=butterflynet-latest make docker-butterflynet-push
172139
fi
173-
# duplicated jobs are for making these jobs' descriptions
174-
# in the pipelines within the CircleCI less confusing
175-
trigger-branch-deployment-for-all-networks:
176-
executor: dockerizer
177-
steps:
178-
- trigger-deployment
179-
trigger-semver-tag-deployment-for-all-networks:
180-
executor: dockerizer
181-
steps:
182-
- trigger-deployment
183140
mod-tidy-check:
184141
executor: golang
185142
steps:
@@ -346,7 +303,7 @@ jobs:
346303
# used in `build-docker-images` workflow below
347304
branch_filters: &branch_filters
348305
branches:
349-
only: /.*deploy.*/
306+
only: /^cd\/staging$/
350307
tags:
351308
ignore: /.*/
352309

@@ -377,19 +334,13 @@ workflows:
377334
- publish-production-image-from-branch-for-mainnet:
378335
filters:
379336
<<: *branch_filters
380-
- publish-production-image-from-branch-for-calibnet:
381-
filters:
382-
<<: *branch_filters
383-
- publish-production-image-from-branch-for-butterflynet:
384-
filters:
385-
<<: *branch_filters
386-
- trigger-branch-deployment-for-all-networks:
387-
requires:
388-
- publish-production-image-from-branch-for-mainnet
389-
- publish-production-image-from-branch-for-calibnet
390-
- publish-production-image-from-branch-for-butterflynet
391-
filters:
392-
<<: *branch_filters
337+
# only publish staging images for mainnet
338+
#- publish-production-image-from-branch-for-calibnet:
339+
#filters:
340+
#<<: *branch_filters
341+
#- publish-production-image-from-branch-for-butterflynet:
342+
#filters:
343+
#<<: *branch_filters
393344
- publish-production-image-from-semver-tag-for-mainnet:
394345
filters:
395346
<<: *tag_filters
@@ -399,11 +350,4 @@ workflows:
399350
- publish-production-image-from-semver-tag-for-butterflynet:
400351
filters:
401352
<<: *tag_filters
402-
- trigger-semver-tag-deployment-for-all-networks:
403-
requires:
404-
- publish-production-image-from-semver-tag-for-mainnet
405-
- publish-production-image-from-semver-tag-for-calibnet
406-
- publish-production-image-from-semver-tag-for-butterflynet
407-
filters:
408-
<<: *tag_filters
409353

0 commit comments

Comments
 (0)