Skip to content

Commit e00051f

Browse files
committed
updated publish action to use docker hub
1 parent b00842c commit e00051f

1 file changed

Lines changed: 17 additions & 32 deletions

File tree

.github/workflows/main-build-publish.yml

Lines changed: 17 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,11 @@ on:
55
branches: [ "main" ]
66

77
env:
8-
# Set the image name to be the GitHub repository, which is 'owner/repo-name'.
9-
# For GHCR, the image will be ghcr.io/owner/repo-name.
10-
# For Docker Hub, you might want something like 'username/repo-name'.
118
IMAGE_NAME: ${{ github.repository }}
129

1310
jobs:
1411
build:
1512
runs-on: ubuntu-latest
16-
# This permission is required to push to GitHub Packages (GHCR).
1713
permissions:
1814
contents: read
1915
packages: write
@@ -37,45 +33,34 @@ jobs:
3733
- name: Set up Docker Buildx
3834
uses: docker/setup-buildx-action@v3
3935

40-
# The user's example used secrets.DOCKER_HUB_TOKEN, which implies Docker Hub.
41-
# However, the 'packages: write' permission is for GHCR.
42-
# This workflow uses GHCR by default as it is more integrated.
43-
# To use Docker Hub, uncomment the Docker Hub login, comment out the GHCR login,
44-
# and ensure your IMAGE_NAME is correct for Docker Hub (e.g., your-username/repo-name).
45-
# You will also need to set DOCKER_HUB_TOKEN and DOCKER_HUB_USERNAME secrets in your repository.
46-
47-
# - name: Log into Docker Hub
48-
# if: github.event_name != 'pull_request'
49-
# uses: docker/login-action@v3
50-
# with:
51-
# username: ${{ secrets.DOCKER_HUB_USERNAME }}
52-
# password: ${{ secrets.DOCKER_HUB_TOKEN }}
53-
54-
- name: Log into GitHub Container Registry
36+
# Login against a Docker registry except on PR
37+
# https://github.com/docker/login-action
38+
- name: Log into registry ${{ env.REGISTRY }}
5539
if: github.event_name != 'pull_request'
56-
uses: docker/login-action@v3
40+
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
5741
with:
58-
registry: ghcr.io
42+
# registry: ${{ env.REGISTRY }}
5943
username: ${{ github.actor }}
60-
password: ${{ secrets.GITHUB_TOKEN }}
61-
44+
password: ${{ secrets.DOCKER_HUB_TOKEN }}
45+
46+
# Extract metadata (tags, labels) for Docker
47+
# https://github.com/docker/metadata-action
6248
- name: Extract Docker metadata
6349
id: meta
64-
uses: docker/metadata-action@v5
50+
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
6551
with:
66-
# For GHCR, the image name is ghcr.io/owner/repo-name.
67-
# For Docker Hub, it would be username/repo-name.
68-
images: ghcr.io/${{ env.IMAGE_NAME }}
69-
# To use Docker Hub, change to:
70-
# images: ${{ secrets.DOCKER_HUB_USERNAME }}/${{ github.event.repository.name }}
71-
52+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
53+
54+
# Build and push Docker image with Buildx (don't push on PR)
55+
# https://github.com/docker/build-push-action
7256
- name: Build and push Docker image
7357
id: build-and-push
74-
uses: docker/build-push-action@v5
58+
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
7559
with:
7660
context: .
7761
push: ${{ github.event_name != 'pull_request' }}
78-
tags: ${{ steps.meta.outputs.tags }}
62+
tags: rohithandique/generic-ui-react
7963
labels: ${{ steps.meta.outputs.labels }}
8064
cache-from: type=gha
8165
cache-to: type=gha,mode=max
66+

0 commit comments

Comments
 (0)