Skip to content

Commit

Permalink
Merge pull request #244 from jhu-idc/image_tags
Browse files Browse the repository at this point in the history
Pushes all images under a unified tag
  • Loading branch information
birkland authored Sep 30, 2021
2 parents a422e26 + 8c48eb9 commit 67c1b7c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
branches:
- main
- development
tags:
- v*
pull_request:
branches:
- main
Expand Down Expand Up @@ -114,6 +116,7 @@ jobs:
needs: [ build, test ]
env:
DOCKER_USER: ${{secrets.DOCKER_USER}}
DOCKER_PUSH_REPOSITORY: ${{secrets.DOCKER_PUSH_REPOSITORY}}
steps:
# Check out current commit
- name: Checkout
Expand Down Expand Up @@ -144,7 +147,7 @@ jobs:
# Push docker images, if we are on the appropriate branch or tag
- name: Docker Push
if: ${{ github.event_name != 'pull_request' && env.DOCKER_USER }}
run: docker-compose push drupal
run: sh tag_and_push_images.sh

# Experimental way to delete artifact
- name: Delete Temporary Images
Expand Down
13 changes: 13 additions & 0 deletions tag_and_push_images.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh

GIT_TAG=$(git describe --tags --always)

for image_uri in $(cat docker-compose.yml | grep ghcr | awk '{print $2}'); do
image_name=$(echo ${image_uri} | tr ':' ' ' | awk '{print $1}' | awk -F "/" '{print $NF}')
echo $image_name

dest_url=${DOCKER_PUSH_REPOSITORY}/${image_name}:${GIT_TAG}

docker tag $image_uri $dest_url
docker push $dest_url
done

0 comments on commit 67c1b7c

Please sign in to comment.