Skip to content

Commit

Permalink
Update docker-publish.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
oproprioleonardo authored Sep 14, 2024
1 parent 62504a7 commit 766b71e
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,24 +78,18 @@ jobs:
- name: Log in to Docker registry
run: echo "${{ secrets.CI_REGISTRY_PASSWORD }}" | docker login ${{ secrets.CI_REGISTRY }} -u "${{ secrets.CI_REGISTRY_USER }}" --password-stdin

- name: Set branch-specific tag
id: tag
- name: Build and push Docker image
run: |
if [[ "${{ github.ref_name }}" == "master" ]]; then
tag="latest"
echo "Running on default branch 'master': tag = 'latest'"
echo "tag=latest" >> $GITHUB_ENV
else
tag="${{ github.ref_name }}"
echo "Running on branch '${{ github.ref_name }}': tag = '${{ github.ref_name }}'"
echo "tag=${{ github.ref_name }}" >> $GITHUB_ENV
fi
- name: Display Docker image tag
run: echo "Docker image will be pushed with tag: ${{ env.tag }}"

- name: Build and push Docker image
run: |
docker build --pull -t ${{ secrets.CI_REGISTRY_IMAGE }}:${{ env.tag }} .
docker push ${{ secrets.CI_REGISTRY_IMAGE }}:${{ env.tag }}
docker build --pull -t ${{ secrets.CI_REGISTRY_IMAGE }}:$tag .
docker push ${{ secrets.CI_REGISTRY_IMAGE }}:$tag
- name: Clean up Docker images
run: docker rmi ${{ secrets.CI_REGISTRY_IMAGE }}:${{ env.tag }} || true
run: |
docker rmi ${{ secrets.CI_REGISTRY_IMAGE }}:$tag || true

0 comments on commit 766b71e

Please sign in to comment.