Skip to content

Commit 2d2c386

Browse files
committed
CI: Build docker image on GHA
1 parent 52eee57 commit 2d2c386

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

.github/workflows/docker.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Docker build
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches: [ "master", "maint/*" ]
7+
tags: "*"
8+
pull_request:
9+
branches: [ "master" ]
10+
11+
env:
12+
REGISTRY: ghcr.io
13+
IMAGE_NAME: ${{ github.repository }}
14+
15+
jobs:
16+
build-container:
17+
runs-on: ubuntu-latest
18+
permissions:
19+
contents: read
20+
packages: write
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v3
24+
25+
- name: Setup Docker buildx
26+
uses: docker/setup-buildx-action@v2
27+
28+
- name: Log into registry ${{ env.REGISTRY }}
29+
if: github.event_name != 'pull_request'
30+
uses: docker/login-action@v2
31+
with:
32+
registry: ${{ env.REGISTRY }}
33+
username: ${{ github.actor }}
34+
password: ${{ secrets.GITHUB_TOKEN }}
35+
36+
- name: Extract Docker metadata
37+
id: meta
38+
uses: docker/metadata-action@v4
39+
with:
40+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
41+
42+
- name: Build and push Docker image
43+
id: build-and-push
44+
uses: docker/build-push-action@v4
45+
with:
46+
context: .
47+
push: ${{ github.event_name != 'pull_request' }}
48+
tags: ${{ steps.meta.outputs.tags }}
49+
labels: ${{ steps.meta.outputs.labels }}
50+
cache-from: type=registry,ref=${{ fromJSON(steps.meta.outputs.json).tags[0] }}
51+
cache-to: inline

0 commit comments

Comments
 (0)