Skip to content

Commit

Permalink
Update push_to_dockerhub.yml
Browse files Browse the repository at this point in the history
Build tagged releases as well
  • Loading branch information
erikglee authored Jan 7, 2025
1 parent b1d9e6a commit 24a4020
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions .github/workflows/push_to_dockerhub.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,49 @@ name: ci
on:
push:
branches:
- "main"
- main
# Any tag that starts with 'v'
tags:
- 'v*'

jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: "lab:latest"
driver: cloud
endpoint: "dcanumn/dcan-cloud-builder-1"

# Dynamically build up the list of image tags
- name: Determine Docker Image Tags
id: vars
run: |
# Always include "latest"
echo "tags=dcanumn/hbcd-made:latest" >> $GITHUB_OUTPUT
# If this is a tag push (refs/tags/v1.2.3, for example),
# also add "dcanumn/hbcd-made:1.2.3"
if [ "${{ github.ref_type }}" = "tag" ]; then
VERSION_TAG="${GITHUB_REF#refs/tags/}"
echo "tags=${{ steps.vars.outputs.tags }},dcanumn/hbcd-made:${VERSION_TAG}" >> $GITHUB_OUTPUT
fi
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
tags: dcanumn/hbcd-made:latest
# For pull requests, export results to the build cache.
# Otherwise, push to a registry.
tags: ${{ steps.vars.outputs.tags }}
# Keep your existing logic for pull requests vs. pushes
outputs: ${{ github.event_name == 'pull_request' && 'type=cacheonly' || 'type=registry,push=true' }}

0 comments on commit 24a4020

Please sign in to comment.