commit | author | age
|
e87b6e
|
1 |
name: Docker |
JK |
2 |
|
|
3 |
on: |
|
4 |
push: |
|
5 |
branches: ['master'] |
|
6 |
tags: ['v*.*.*'] |
|
7 |
pull_request: |
|
8 |
branches: ['master'] |
|
9 |
|
|
10 |
env: |
|
11 |
REGISTRY: ghcr.io |
|
12 |
IMAGE_NAME: ${{ github.repository }} |
|
13 |
|
|
14 |
jobs: |
|
15 |
build: |
|
16 |
|
|
17 |
runs-on: ubuntu-latest |
|
18 |
permissions: |
|
19 |
contents: read |
|
20 |
packages: write |
|
21 |
|
|
22 |
steps: |
|
23 |
- name: Checkout repository |
|
24 |
uses: actions/checkout@v4 |
|
25 |
|
|
26 |
- name: Set up Docker Buildx |
|
27 |
uses: docker/setup-buildx-action@v3.0.0 |
|
28 |
|
|
29 |
- name: Log into ${{ env.REGISTRY }} registry |
|
30 |
if: github.event_name != 'pull_request' |
|
31 |
uses: docker/login-action@v3.0.0 |
|
32 |
with: |
|
33 |
registry: ${{ env.REGISTRY }} |
|
34 |
username: ${{ github.actor }} |
|
35 |
password: ${{ secrets.GITHUB_TOKEN }} |
|
36 |
|
|
37 |
- name: Extract Docker metadata |
|
38 |
id: meta |
|
39 |
uses: docker/metadata-action@v5.0.0 |
|
40 |
with: |
|
41 |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
|
42 |
|
|
43 |
- name: Build and push Docker image |
|
44 |
id: build-and-push |
|
45 |
uses: docker/build-push-action@v5.0.0 |
|
46 |
with: |
|
47 |
context: . |
|
48 |
push: ${{ github.event_name != 'pull_request' }} |
|
49 |
tags: ${{ steps.meta.outputs.tags }} |
|
50 |
labels: ${{ steps.meta.outputs.labels }} |
|
51 |
cache-from: type=gha |
|
52 |
cache-to: type=gha,mode=max |