Skip to content

Commit

Permalink
Only push versioned docker images on tag (#9192)
Browse files Browse the repository at this point in the history
  • Loading branch information
castrapel authored Jul 30, 2021
1 parent 310441c commit b107ece
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 16 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/create-release-on-tag-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: create_release

on:
push:
tags:
- "*"

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ncipollo/release-action@v1
with:
token: ${{ secrets.CONSOLEME_GITHUB_TOKEN_CREATE_RELEASE }}
19 changes: 11 additions & 8 deletions .github/workflows/docker-publish-dockerhub.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,23 @@ jobs:
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Tag, and push image to DockerHub
- name: Tag, and push unstable image to DockerHub
run: |
docker tag consoleme consoleme/consoleme:unstable
docker push --all-tags consoleme/consoleme
- name: Tag, and push versioned image to DockerHub on tag
if: github.event_name == 'create' && startsWith(github.ref, 'refs/tags/v')
run: |
export CONSOLEME_VERSION=$(python3 setup.py -q --version | sed -r 's/\+/\./g')
export CONSOLEME_MAJOR=$(cut -d '.' -f 1 <<< "$CONSOLEME_VERSION")
export CONSOLEME_MINOR=$(cut -d '.' -f 1,2 <<< "$CONSOLEME_VERSION")
export CONSOLEME_PATCH=$(cut -d '.' -f 1,2,3 <<< "$CONSOLEME_VERSION")
export CONSOLEME_DEV=$(cut -d '.' -f 1,2,3,4 <<< "$CONSOLEME_VERSION")
docker tag consoleme:latest consoleme/consoleme:latest
docker tag consoleme:latest consoleme/consoleme:$CONSOLEME_VERSION
docker tag consoleme:latest consoleme/consoleme:$CONSOLEME_MAJOR
docker tag consoleme:latest consoleme/consoleme:$CONSOLEME_MINOR
docker tag consoleme:latest consoleme/consoleme:$CONSOLEME_PATCH
docker tag consoleme:latest consoleme/consoleme:$CONSOLEME_DEV
docker tag consoleme consoleme/consoleme:$CONSOLEME_VERSION
docker tag consoleme consoleme/consoleme:$CONSOLEME_MAJOR
docker tag consoleme consoleme/consoleme:$CONSOLEME_MINOR
docker tag consoleme consoleme/consoleme:$CONSOLEME_PATCH
docker push --all-tags consoleme/consoleme
deploy_consoleme_demo_site:
name: Deploy Demo Site
if: github.repository == 'Netflix/consoleme'
Expand Down
18 changes: 10 additions & 8 deletions .github/workflows/docker-publish-ecr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,21 @@ jobs:
- name: Build ConsoleMe
run: |
docker build -t consoleme .
- name: Tag, and push image to Amazon ECR
- name: Tag, and push unstable image to Amazon ECR
run: |
docker tag consoleme public.ecr.aws/consoleme/consoleme:unstable
docker push --all-tags public.ecr.aws/consoleme/consoleme
- name: Tag, and push versioned image to DockerHub on tag
if: github.event_name == 'create' && startsWith(github.ref, 'refs/tags/v')
run: |
# Extract tags from version
export CONSOLEME_VERSION=$(python3 setup.py -q --version | sed -r 's/\+/\./g')
export CONSOLEME_MAJOR=$(cut -d '.' -f 1 <<< "$CONSOLEME_VERSION")
export CONSOLEME_MINOR=$(cut -d '.' -f 1,2 <<< "$CONSOLEME_VERSION")
export CONSOLEME_PATCH=$(cut -d '.' -f 1,2,3 <<< "$CONSOLEME_VERSION")
export CONSOLEME_DEV=$(cut -d '.' -f 1,2,3,4 <<< "$CONSOLEME_VERSION")
# Tag image
docker tag consoleme:latest public.ecr.aws/consoleme/consoleme:latest
docker tag consoleme:latest public.ecr.aws/consoleme/consoleme:$CONSOLEME_VERSION
docker tag consoleme:latest public.ecr.aws/consoleme/consoleme:$CONSOLEME_MAJOR
docker tag consoleme:latest public.ecr.aws/consoleme/consoleme:$CONSOLEME_MINOR
docker tag consoleme:latest public.ecr.aws/consoleme/consoleme:$CONSOLEME_PATCH
docker tag consoleme:latest public.ecr.aws/consoleme/consoleme:CONSOLEME_DEV
docker tag consoleme public.ecr.aws/consoleme/consoleme:$CONSOLEME_VERSION
docker tag consoleme public.ecr.aws/consoleme/consoleme:$CONSOLEME_MAJOR
docker tag consoleme public.ecr.aws/consoleme/consoleme:$CONSOLEME_MINOR
docker tag consoleme public.ecr.aws/consoleme/consoleme:$CONSOLEME_PATCH
docker push --all-tags public.ecr.aws/consoleme/consoleme

0 comments on commit b107ece

Please sign in to comment.