-
Notifications
You must be signed in to change notification settings - Fork 16
69 lines (67 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
name: Docker Build
on:
push:
branches:
- master
pull_request:
branches:
- master
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')
-
name: Set up Docker Buildx
id: buildx
uses: crazy-max/ghaction-docker-buildx@v1
with:
version: latest
-
name: Available platforms
run: echo ${{ steps.build.outputs.platforms }}
-
name: Login to DockerHub Registry
run: echo ${{ secrets.DOCKER_HUB_PASSWORD }} | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin
-
name: Build
run: |
docker buildx build \
--output "type=image,push=false" \
--platform linux/amd64,linux/arm/v7 \
--cache-from=type=registry,ref=kegbot/pycore \
--cache-to=type=registry,ref=kegbot/pycore \
--build-arg "BUILD_DATE=${{ steps.prepare.outputs.build_date }}" \
--build-arg "GIT_SHORT_SHA=${GITHUB_SHA::8}" \
--build-arg "VERSION=${{ steps.prepare.outputs.version }}" \
--tag "kegbot/pycore:${{ steps.prepare.outputs.version }}" \
--tag "kegbot/pycore:latest" \
.
-
name: Publish
if: success() && github.ref == 'refs/heads/master'
run: |
docker buildx build \
--output "type=image,push=true" \
--platform linux/amd64,linux/arm/v7 \
--cache-from=type=registry,ref=kegbot/pycore \
--build-arg "BUILD_DATE=${{ steps.prepare.outputs.build_date }}" \
--build-arg "GIT_SHORT_SHA=${GITHUB_SHA::8}" \
--build-arg "VERSION=${{ steps.prepare.outputs.version }}" \
--tag "kegbot/pycore:${{ steps.prepare.outputs.version }}" \
--tag "kegbot/pycore:latest" \
.