Skip to content

Commit 09c7358

Browse files
committed
Add dockerhub publish workflow
1 parent 6b8196b commit 09c7358

1 file changed

Lines changed: 58 additions & 0 deletions

File tree

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Build And Publish Container
2+
3+
on:
4+
push:
5+
branches:
6+
- docker-publish
7+
tags:
8+
- 'v*'
9+
pull_request:
10+
branches:
11+
- docker-publish
12+
workflow_dispatch:
13+
14+
env:
15+
DOCKERHUB_IMAGE: tatevikg1/phplist4
16+
17+
jobs:
18+
docker:
19+
runs-on: ubuntu-22.04
20+
permissions:
21+
contents: read
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v4
25+
26+
- name: Set up QEMU
27+
uses: docker/setup-qemu-action@v3
28+
29+
- name: Set up Docker Buildx
30+
uses: docker/setup-buildx-action@v3
31+
32+
- name: Log in to Docker Hub
33+
if: github.event_name != 'pull_request'
34+
uses: docker/login-action@v3
35+
with:
36+
username: ${{ secrets.DOCKERHUB_USERNAME }}
37+
password: ${{ secrets.DOCKERHUB_TOKEN }}
38+
39+
- name: Extract Docker metadata
40+
id: meta
41+
uses: docker/metadata-action@v5
42+
with:
43+
images: ${{ env.DOCKERHUB_IMAGE }}
44+
tags: |
45+
type=raw,value=test,enable={{is_default_branch}}
46+
type=ref,event=tag
47+
type=sha,prefix=sha-
48+
49+
- name: Build and push image
50+
uses: docker/build-push-action@v6
51+
with:
52+
context: .
53+
file: ./Dockerfile
54+
platforms: linux/amd64,linux/arm64
55+
push: ${{ github.event_name != 'pull_request' }}
56+
tags: ${{ steps.meta.outputs.tags }}
57+
labels: ${{ steps.meta.outputs.labels }}
58+

0 commit comments

Comments
 (0)