Skip to content

Commit

Permalink
(github-actions) Tag Docker images with commit SHA
Browse files Browse the repository at this point in the history
  • Loading branch information
axel-op committed Mar 3, 2024
1 parent d827073 commit 9d24c66
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ jobs:

env:
DOCKERFILE: Dockerfile-parent
GHCR_IMAGE_TAG: "ghcr.io/${{ github.repository }}:v3"
GHCR_IMAGE: "ghcr.io/${{ github.repository }}"
GHCR_IMAGE_TAG_1: "ghcr.io/${{ github.repository }}:v3"
GHCR_IMAGE_TAG_2: "ghcr.io/${{ github.repository }}:${{ github.sha }}"
DOCKER_HUB_IMAGE_TAG: "axelop/dart_package_analyzer:v3"
REGISTRY: ghcr.io
GHCR_REGISTRY: ghcr.io

steps:
- uses: actions/checkout@v4
Expand All @@ -32,7 +34,7 @@ jobs:
uses: axel-op/docker-labels-retriever@master
with:
image: ${{ env.GHCR_IMAGE_TAG }}
registry: ${{ env.REGISTRY }}
registry: ${{ env.GHCR_REGISTRY }}

- name: Check current image
id: check
Expand Down Expand Up @@ -98,14 +100,7 @@ jobs:
DOCKER_HUB_USERNAME: axelop
DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_TOKEN }}
run: |
echo $GHCR_TOKEN | sudo docker login $REGISTRY --username=$GHCR_USERNAME --password-stdin
sudo docker push $GHCR_IMAGE_TAG
echo $GHCR_TOKEN | sudo docker login $GHCR_REGISTRY --username=$GHCR_USERNAME --password-stdin
sudo docker push --all-tags $GHCR_IMAGE
echo $DOCKER_HUB_TOKEN | sudo docker login --username=$DOCKER_HUB_USERNAME --password-stdin
sudo docker push $DOCKER_HUB_IMAGE_TAG
- name: Delete untagged image versions
uses: actions/delete-package-versions@v4
with:
package-name: ${{ github.event.repository.name }}
package-type: container
delete-only-untagged-versions: true

0 comments on commit 9d24c66

Please sign in to comment.