Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ci): Create docker images for commits in cd/staging #1090

Merged
merged 4 commits into from
Nov 16, 2022
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 10 additions & 66 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,40 +35,6 @@ commands:
- run: git submodule sync
- run: sudo apt-get install gcc libc-dev
- run: git submodule update --init
trigger-deployment:
steps:
- checkout
- run:
name: Trigger deployment for filecoin-project/lily
command: |
# derive docker image deploy-tag according to the publish-* steps in this config
branch_tag_suffix=`echo "$CIRCLE_SHA1" | cut -c 1-8`
sanitized_branch=`echo $CIRCLE_BRANCH | sed 's:/:-:g'`
deploy_branch=${sanitized_branch}-${branch_tag_suffix}
sanitized_tag=`echo $CIRCLE_TAG | sed 's:/:-:g'`

# if $sanitized_tag is empty, default to $sanitized_branch
deploy_target=${sanitized_tag:-$deploy_branch}

# curlf fails with a non-zero exit code when the status code is not 2XX
curlf() {
OUTPUT_FILE=$(mktemp)
HTTP_CODE=$(curl --silent --output $OUTPUT_FILE --write-out "%{http_code}" "$@")
if [[ ${HTTP_CODE} -lt 200 || ${HTTP_CODE} -gt 299 ]] ; then
>&2 cat $OUTPUT_FILE
return 22
fi
cat $OUTPUT_FILE
rm $OUTPUT_FILE
}

# trigger deployment in sentinel-infra repo
curlf --request POST \
--url https://circleci.com/api/v2/project/gh/filecoin-project/sentinel-infra/pipeline \
--header "Circle-Token: $SENTINEL_INFRA_CIRCLECI_API_TOKEN" \
--header "content-type: application/json" \
--data "{\"branch\":\"master\",\"parameters\":{\"trigger-deploy\": true, \"deploy-tag\":\"$deploy_target\"}}"
echo ""
validate-docker-executeable:
steps:
- run:
Expand All @@ -89,7 +55,8 @@ jobs:
echo "$DOCKERHUB_PASS" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin
sanitized_branch=`echo $CIRCLE_BRANCH | sed 's:/:-:g'`
tag_suffix=$(echo "$CIRCLE_SHA1" | cut -c 1-8)
make docker-mainnet-push LILY_IMAGE_TAG=${sanitized_branch}-${tag_suffix}
tag_date=$(date +%Y%m%d%H%M)
make docker-mainnet-push LILY_IMAGE_TAG=${sanitized_branch}-${tag_date}-${tag_suffix}
Copy link
Contributor Author

@placer14 placer14 Nov 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new docker image tags that are created look like cd-staging-${tag_date}-${tag_suffix}. This is what we will filter on when deciding what to deploy into staging.

publish-production-image-from-branch-for-calibnet:
executor: dockerizer
steps:
Expand Down Expand Up @@ -170,16 +137,6 @@ jobs:
if [[ "$CIRCLE_TAG" =~ ^(v[0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
LILY_IMAGE_TAG=butterflynet-latest make docker-butterflynet-push
fi
# duplicated jobs are for making these jobs' descriptions
# in the pipelines within the CircleCI less confusing
trigger-branch-deployment-for-all-networks:
executor: dockerizer
steps:
- trigger-deployment
trigger-semver-tag-deployment-for-all-networks:
executor: dockerizer
steps:
- trigger-deployment
mod-tidy-check:
executor: golang
steps:
Expand Down Expand Up @@ -346,7 +303,7 @@ jobs:
# used in `build-docker-images` workflow below
branch_filters: &branch_filters
branches:
only: /.*deploy.*/
only: /cd\/staging/
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are reusing prior behavior. This causes us to detect changes on cd/staging and trigger this job.

tags:
ignore: /.*/

Expand Down Expand Up @@ -377,19 +334,13 @@ workflows:
- publish-production-image-from-branch-for-mainnet:
filters:
<<: *branch_filters
- publish-production-image-from-branch-for-calibnet:
filters:
<<: *branch_filters
- publish-production-image-from-branch-for-butterflynet:
filters:
<<: *branch_filters
- trigger-branch-deployment-for-all-networks:
requires:
- publish-production-image-from-branch-for-mainnet
- publish-production-image-from-branch-for-calibnet
- publish-production-image-from-branch-for-butterflynet
filters:
<<: *branch_filters
# only publish staging images for mainnet
#- publish-production-image-from-branch-for-calibnet:
#filters:
#<<: *branch_filters
#- publish-production-image-from-branch-for-butterflynet:
#filters:
#<<: *branch_filters
- publish-production-image-from-semver-tag-for-mainnet:
filters:
<<: *tag_filters
Expand All @@ -399,11 +350,4 @@ workflows:
- publish-production-image-from-semver-tag-for-butterflynet:
filters:
<<: *tag_filters
- trigger-semver-tag-deployment-for-all-networks:
requires:
- publish-production-image-from-semver-tag-for-mainnet
- publish-production-image-from-semver-tag-for-calibnet
- publish-production-image-from-semver-tag-for-butterflynet
filters:
<<: *tag_filters