-
Notifications
You must be signed in to change notification settings - Fork 1
88 lines (74 loc) · 2.28 KB
/
docker.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
name: Build 0KN Node Docker Image
on:
pull_request:
branches:
- main
push:
branches:
- main
paths-ignore:
- '**/*.md'
- 'docs/**'
- 'tests/**'
tags:
- "v*"
permissions:
contents: read
packages: write
jobs:
build-push-docker-image:
runs-on: ubuntu-latest
env:
IMAGE: ghcr.io/${{ github.repository_owner }}/node
IMAGE_TEST: zkn/node
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.IMAGE }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=latest,enable={{is_default_branch}}
type=sha
# https://docs.docker.com/build/ci/github-actions/reproducible-builds/
- name: Set source build date from git commit timestamp
run: echo "SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct)" >> $GITHUB_ENV
- name: Build and export to Docker
uses: docker/build-push-action@v6
env:
DOCKER_BUILD_SUMMARY: false
with:
file: ./docker/node/Dockerfile
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ${{ env.IMAGE_TEST }}:test
load: true
- name: Test docker image
run: docker run --rm ${{ env.IMAGE_TEST }}:test /bin/bash -c 'ls -l /opt/zkn/'
- name: Docker build and push
uses: docker/build-push-action@v6
with:
file: ./docker/node/Dockerfile
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64
push: ${{ github.event_name != 'pull_request' }}
- name: List docker images
run: docker images