Skip to content

Commit eb69962

Browse files
authored
build and publish image to Docker Hub (alexjustesen#203)
1 parent 010cdd5 commit eb69962

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

.github/workflows/publish-image.yml

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ env:
2121
PLATFORMS: linux/amd64,linux/arm64,linux/arm/v7
2222

2323
jobs:
24-
build-and-push-image:
25-
runs-on: ubuntu-latest
24+
build_and_push_image:
25+
name: Build and push Docker image
26+
runs-on: ubuntu-22.04
2627
permissions:
2728
contents: read
2829
packages: write
@@ -50,11 +51,31 @@ jobs:
5051
with:
5152
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
5253

53-
- name: Build and push Docker image
54+
- name: Build and push image to GHCR
5455
uses: docker/build-push-action@v3
5556
with:
5657
context: .
5758
push: true
5859
platforms: ${{ env.PLATFORMS }}
5960
tags: ${{ steps.meta.outputs.tags }}
6061
labels: ${{ steps.meta.outputs.labels }}
62+
63+
- name: Log in to Docker Hub
64+
uses: docker/login-action@v2
65+
with:
66+
username: ${{ secrets.DOCKER_USERNAME }}
67+
password: ${{ secrets.DOCKER_PASSWORD }}
68+
69+
- name: Extract metadata (tags, labels) for Docker
70+
id: meta
71+
uses: docker/metadata-action@v4
72+
with:
73+
images: ajustesen/${{ env.IMAGE_NAME }}
74+
75+
- name: Build and push image to Docker Hub
76+
uses: docker/build-push-action@v3
77+
with:
78+
context: .
79+
push: true
80+
tags: ${{ steps.meta.outputs.tags }}
81+
labels: ${{ steps.meta.outputs.labels }}

0 commit comments

Comments
 (0)