-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1808aeb
commit 0f0232c
Showing
1 changed file
with
96 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
version: 2 | ||
jobs: | ||
# NOTE: This job shouldn't be necessary. Including it for now though to maintain current practices. | ||
test-branch-name: | ||
machine: true | ||
steps: | ||
- checkout | ||
- run: | ||
name: Check for reserved branch names | ||
command: | | ||
important_branches=( $(ls -d * | grep milmove) latest ) | ||
for branch in "${important_branches[@]}" | ||
do | ||
if test "${CIRCLE_BRANCH}" == ${branch} | ||
then | ||
echo "Don't use meaningful tags for a branch name!" | ||
echo "Don't use a branch named ${branch}." | ||
exit 1 | ||
fi | ||
done | ||
build: | ||
machine: true | ||
steps: | ||
- checkout | ||
- run: | ||
name: Login to Docker Hub | ||
command: docker login -u $DOCKER_USER -p $DOCKER_PASS | ||
|
||
- run: | ||
name: Build containers | ||
command: make build | ||
|
||
- run: | ||
name: Test containers | ||
command: make test | ||
|
||
- run: | ||
name: Release container | ||
command: | | ||
shopt -s extglob | ||
for tag in $CIRCLE_SHA1 ${CIRCLE_BRANCH//+([^A-Za-z0-9-.])/-}; do | ||
# latest | ||
docker tag milmove/circleci-docker milmove/circleci-docker:$tag | ||
docker push milmove/circleci-docker:$tag | ||
# milmove-app | ||
docker tag milmove/circleci-docker:milmove-app milmove/circleci-docker:milmove-app-$tag | ||
docker push milmove/circleci-docker:milmove-app-$tag | ||
# milmove-cypress | ||
docker tag milmove/circleci-docker:milmove-cypress milmove/circleci-docker:milmove-cypress-$tag | ||
docker push milmove/circleci-docker:milmove-cypress-$tag | ||
# milmove-infra-tf112 | ||
docker tag milmove/circleci-docker:milmove-infra-tf112 milmove/circleci-docker:milmove-infra-tf112-$tag | ||
docker push milmove/circleci-docker:milmove-infra-tf112-$tag | ||
# milmove-infra-tf132 | ||
docker tag milmove/circleci-docker:milmove-infra-tf132 milmove/circleci-docker:milmove-infra-tf132-$tag | ||
docker push milmove/circleci-docker:milmove-infra-tf132-$tag | ||
# milmove-atlantis | ||
docker tag milmove/circleci-docker:milmove-atlantis milmove/circleci-docker:milmove-atlantis-$tag | ||
docker push milmove/circleci-docker:milmove-atlantis-$tag | ||
done | ||
# push default tags on main | ||
if [[ $CIRCLE_BRANCH = main ]]; then | ||
docker push milmove/circleci-docker | ||
docker push milmove/circleci-docker:milmove-app | ||
docker push milmove/circleci-docker:milmove-cypress | ||
docker push milmove/circleci-docker:milmove-infra-tf112 | ||
docker push milmove/circleci-docker:milmove-infra-tf132 | ||
docker push milmove/circleci-docker:milmove-atlantis | ||
fi | ||
workflows: | ||
version: 2 | ||
build-containers: | ||
jobs: | ||
- test-branch-name | ||
- build: | ||
requires: | ||
- test-branch-name | ||
filters: | ||
branches: | ||
# NOTE: These branches are ignored because we use them when | ||
# building containers for the application and infrastructure. | ||
ignore: | ||
- latest | ||
- milmove-app | ||
- milmove-atlantis | ||
- milmove-cypress | ||
- milmove-infra-tf132 | ||
- milmove-infra-tf112 |