forked from Kegbot/kegbot-server
-
Notifications
You must be signed in to change notification settings - Fork 0
122 lines (110 loc) · 3.76 KB
/
Copy pathdocker.yml
File metadata and controls
122 lines (110 loc) · 3.76 KB
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
name: Docker Build
env:
IMAGE_NAME: kegbot/server
REGISTRY: ghcr.io
on:
push:
branches:
- main
tags:
- 'v*'
- stable
pull_request:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Prepare
id: prepare
run: |
if [[ $GITHUB_REF == refs/tags/* ]]; then
TAG=${GITHUB_REF#refs/tags/}
echo ::set-output name=tag_name::${TAG}
echo ::set-output name=version::${TAG%-*}
else
echo ::set-output name=version::snapshot
fi
echo ::set-output name=build_date::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
# Work around an armv7 -> qemu bug caused during rust compilation. Yeah.. See repo.
- name: Run Docker on tmpfs
uses: JonasAlfredsson/docker-on-tmpfs@v1
with:
tmpfs_size: 8
swap_size: 8
swap_location: '/mnt/swapfile'
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
# Set up the tag(s) we will build/push. The `metadata-action` action has
# a bunch of rules and a little language for specifying this. This should
# be how it's configured:
#
# =================== ============================= =============
# When What Example
# =================== ============================= =============
# All runs "dev" dev
# Merge to main "latest" latest
# Merge tag <tag> v1.2.3b1
# Merge semver tag <semver> 1.2.3
# Merge semver tag <major>.<minor> 1.2
-
name: Set up docker tag names
id: docker_meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=dev
type=raw,value=latest,enable={{is_default_branch}}
type=ref,event=tag
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Build locally
uses: docker/build-push-action@v3
with:
context: .
cache-from: type=gha
cache-to: type=gha,mode=max
push: false
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
BUILD_DATE=${{ steps.prepare.outputs.build_date }}
GIT_SHORT_SHA=${GITHUB_SHA::8}
VERSION=${{ steps.prepare.outputs.version }}
platforms: |
linux/amd64
linux/arm64
linux/arm/v7
- name: Log in to container registry
if: ${{ '${{ secrets.GITHUB_TOKEN }}' != '' }}
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push to container registry
if: ${{ '${{ secrets.GITHUB_TOKEN }}' != '' }}
uses: docker/build-push-action@v3
with:
context: .
cache-from: type=gha
cache-to: type=gha,mode=max
push: true
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
BUILD_DATE=${{ steps.prepare.outputs.build_date }}
GIT_SHORT_SHA=${GITHUB_SHA::8}
VERSION=${{ steps.prepare.outputs.version }}
platforms: |
linux/amd64
linux/arm64
linux/arm/v7