Skip to content

Commit 3d4647f

Browse files
authored
Create docker-image.yaml
1 parent dc2e4c6 commit 3d4647f

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

.github/workflows/docker-image.yaml

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Build and publish a Docker image
2+
on:
3+
push:
4+
branches:
5+
- '*'
6+
tags:
7+
- 'v[0-9]+.[0-9]+.[0-9]+'
8+
pull_request:
9+
branches:
10+
- '*'
11+
jobs:
12+
build:
13+
name: Build & push docker image
14+
runs-on: ubuntu-latest
15+
env:
16+
IMG_NAME: ${{ github.repository }}
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v3
20+
21+
- name: Debug
22+
run: |
23+
echo "github.ref -> {{ github.ref }}"
24+
25+
- name: Docker metadata
26+
id: metadata
27+
uses: docker/metadata-action@v3
28+
with:
29+
images: ${{ env.IMG_NAME }}
30+
tags: |
31+
type=semver,pattern={{version}}
32+
type=semver,pattern={{major}}.{{minor}}
33+
type=raw,value={{sha}},enable=${{ github.ref_type != 'tag' }}
34+
35+
- name: Log in to Docker Hub
36+
uses: docker/login-action@v1
37+
if: ${{ github.ref_type == 'tag' }}
38+
with:
39+
username: ${{ secrets.DOCKER_USERNAME }}
40+
password: ${{ secrets.DOCKER_PASSWORD }}
41+
42+
- name: Build and push Docker image
43+
uses: docker/build-push-action@v2
44+
with:
45+
context: .
46+
push: ${{ github.event.base_ref =='refs/heads/main' && github.ref_type == 'tag' && !startsWith(github.ref, 'refs/tags/v0.')}}
47+
tags: ${{ steps.metadata.outputs.tags }}
48+
labels: ${{ steps.metadata.outputs.labels }}

0 commit comments

Comments
 (0)