Skip to content

Commit 6d4df79

Browse files
committed
Add ghcr.io images build and push
1 parent 7fcf0ab commit 6d4df79

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

.github/workflows/docker.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Docker images
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
tags: [ 'v*' ]
7+
pull_request:
8+
branches: [ master ]
9+
10+
jobs:
11+
docker:
12+
name: Build image
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Check out code
16+
uses: actions/checkout@v2
17+
- name: Docker meta
18+
id: meta
19+
uses: docker/metadata-action@v3
20+
with:
21+
images: ghcr.io/${{ github.repository }}
22+
# create latest tag for branch events
23+
flavor: |
24+
latest=${{ github.event_name == 'push' && github.ref_type == 'branch' }}
25+
tags: |
26+
type=ref,event=branch
27+
type=ref,event=pr
28+
type=semver,pattern={{version}}
29+
type=semver,pattern={{major}}.{{minor}}
30+
type=semver,pattern={{major}}.{{minor}}.{{patch}}
31+
- name: Login to DockerHub
32+
if: github.event_name != 'pull_request'
33+
uses: docker/login-action@v1
34+
with:
35+
registry: ghcr.io
36+
username: ${{ github.actor }}
37+
password: ${{ secrets.GITHUB_TOKEN }}
38+
- name: Build and push
39+
id: docker_build
40+
uses: docker/build-push-action@v2
41+
with:
42+
# push for non-pr events
43+
push: ${{ github.event_name != 'pull_request' }}
44+
context: .
45+
tags: ${{ steps.meta.outputs.tags }}
46+
labels: ${{ steps.meta.outputs.labels }}
47+

0 commit comments

Comments
 (0)