From 4c8fa10a066a809338e142b4a457a4bab77ca027 Mon Sep 17 00:00:00 2001 From: Jon Jagger Date: Sat, 23 Mar 2024 10:34:51 +0000 Subject: [PATCH] Add ci workflow job to push image tagged with :latest (#178) --- .github/workflows/main.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4182acf..69aa962 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -312,3 +312,29 @@ jobs: with: IMAGE_TAG: ${{ needs.kosli-trail.outputs.image_tag }} + + # The cyberdojo/versioner refresh-env.sh script + # https://github.com/cyber-dojo/versioner/blob/master/sh/refresh-env.sh + # relies on being able to: + # - get the :latest image + # - extract the SHA env-var embedded inside it + # - use the 1st 7 chars of the SHA as a latest-equivalent tag + + push-latest: + needs: [deploy-to-prod, kosli-trail] + runs-on: ubuntu-latest + env: + IMAGE_NAME: ${{ needs.kosli-trail.outputs.image_name }} + steps: + - uses: actions/checkout@v4 + + - uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USER }} + password: ${{ secrets.DOCKER_PASS }} + + - name: Tag image to :latest and push to Dockerhub Registry + run: | + docker pull "${IMAGE_NAME}" + docker tag "${IMAGE_NAME}" cyberdojo/${{ env.SERVICE_NAME }}:latest + docker push cyberdojo/${{ env.SERVICE_NAME }}:latest \ No newline at end of file