Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: try out docker image push by tags #3704

Merged
merged 13 commits into from
Jul 7, 2023
27 changes: 23 additions & 4 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,35 @@ jobs:
push_to_registry:
name: Build and push Docker image to Docker Hub
runs-on: ubuntu-latest

steps:
- name: Check out the repo
- name: Check out the repo with latest code
uses: actions/checkout@v3
- name: Push latest to Docker Hub
uses: docker/build-push-action@v1 # Info: https://github.com/docker/build-push-action/tree/releases/v1#tags
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
repository: ${{ secrets.DOCKERHUB_REPOSITORY }}
tag_with_ref: true # Info: https://github.com/docker/build-push-action/tree/releases/v1#tag_with_ref
tag_with_sha: true # Info: https://github.com/docker/build-push-action/tree/releases/v1#tag_with_sha
tags: latest

- name: 'Get the current tag'
id: currentTag
uses: actions/checkout@v3
- run: git fetch --prune --unshallow && TAG=$(git describe --tags --abbrev=0) && echo $TAG && echo "TAG="$TAG >> "$GITHUB_ENV"
- name: Check out the repo with tag
uses: actions/checkout@v3
with:
ref: ${{ env.TAG }}

- name: Push to Docker Hub
uses: docker/build-push-action@v4 # Info: https://github.com/docker/build-push-action/tree/releases/v1#tags
- name: Push current tag to Docker Hub
uses: docker/build-push-action@v1 # Info: https://github.com/docker/build-push-action/tree/releases/v1#tags
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
repository: ${{ secrets.DOCKERHUB_REPOSITORY }}
tag_with_ref: true # Info: https://github.com/docker/build-push-action/tree/releases/v1#tag_with_ref
tag_with_sha: true # Info: https://github.com/docker/build-push-action/tree/releases/v1#tag_with_sha
tags: latest
tags: ${{ env.TAG }}