From 99fd0c9a2dc77ea68b0eb0c3d146d416e1de778f Mon Sep 17 00:00:00 2001 From: Mariano Ruiz Date: Wed, 17 Apr 2024 17:22:42 -0300 Subject: [PATCH 1/3] Publish docker image from CI --- .github/workflows/docker-image.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 9c48fc4..3977242 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -11,7 +11,14 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Build the Docker image run: ./docker-build.sh "${GITHUB_REF#refs/heads/}" - name: Run tests run: docker run --rm -e PROCESS_TYPE=test --name django-coleman "mrsarm/django-coleman:${GITHUB_REF#refs/heads/}" + - name: Push Docker image + run: docker push "mrsarm/django-coleman:${GITHUB_REF#refs/heads/}" From c684d49c3a3ddea33de011db37eb62ad37e06dba Mon Sep 17 00:00:00 2001 From: Mariano Ruiz Date: Wed, 17 Apr 2024 17:27:37 -0300 Subject: [PATCH 2/3] Slug version of branch for tag --- .github/workflows/docker-image.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 3977242..75aa4d1 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -11,14 +11,16 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Inject slug/short variables + uses: rlespinasse/github-slug-action@v4 - name: Login to Docker Hub uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Build the Docker image - run: ./docker-build.sh "${GITHUB_REF#refs/heads/}" + run: ./docker-build.sh "${GITHUB_REF_SLUG}" - name: Run tests - run: docker run --rm -e PROCESS_TYPE=test --name django-coleman "mrsarm/django-coleman:${GITHUB_REF#refs/heads/}" + run: docker run --rm -e PROCESS_TYPE=test --name django-coleman "mrsarm/django-coleman:${GITHUB_REF_SLUG}" - name: Push Docker image - run: docker push "mrsarm/django-coleman:${GITHUB_REF#refs/heads/}" + run: docker push "mrsarm/django-coleman:${GITHUB_REF_SLUG}" From 52856c08f5cc243b56e5c47581c33cf45417c397 Mon Sep 17 00:00:00 2001 From: Mariano Ruiz Date: Wed, 17 Apr 2024 17:56:15 -0300 Subject: [PATCH 3/3] Release latest on master --- .github/workflows/docker-image.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 75aa4d1..bd29ca5 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -24,3 +24,9 @@ jobs: run: docker run --rm -e PROCESS_TYPE=test --name django-coleman "mrsarm/django-coleman:${GITHUB_REF_SLUG}" - name: Push Docker image run: docker push "mrsarm/django-coleman:${GITHUB_REF_SLUG}" + - name: Tag "latest" + if: ${{ github.ref == 'refs/heads/master' }} + run: docker tag "mrsarm/django-coleman:${GITHUB_REF_SLUG}" mrsarm/django-coleman:latest + - name: Release "latest" + if: ${{ github.ref == 'refs/heads/master' }} + run: docker push mrsarm/django-coleman:latest