Created
September 5, 2020 07:09
-
-
Save fujimaki-k/9c51a25fd4fbf796fd00d2e4c5facb12 to your computer and use it in GitHub Desktop.
CircleCI config.yml sample
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
version: 2.1 | |
commands: | |
buildimage: | |
description: "Build docker image" | |
steps: | |
- checkout | |
- setup_remote_docker | |
- run: | |
name: "Install git command" | |
command: "apk add git" | |
- run: | |
name: "Build docker image" | |
command: | | |
FILES=$(git log --max-count 1 --name-only --oneline | awk 'NR>1 {print}' | grep Dockerfile) | |
for FILE in $FILES | |
do | |
IMAGE=$(dirname "$FILE") | |
docker build --force-rm --no-cache --pull --rm --squash --tag $IMAGE $IMAGE | |
done | |
- run: | |
name: "Push docker image to registry" | |
command: | | |
FILES=$(git log --max-count 1 --name-only --oneline | awk 'NR>1 {print}' | grep Dockerfile) | |
for FILE in $FILES | |
do | |
IMAGE=$(dirname "$FILE") | |
docker push $IMAGE | |
done | |
executors: | |
default: | |
docker: | |
- image: docker:stable | |
jobs: | |
build: | |
executor: default | |
steps: | |
- buildimage |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment