-
Notifications
You must be signed in to change notification settings - Fork 0
89 lines (79 loc) · 2.76 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
89
# SPDX-FileCopyrightText: 2021 Robin Vobruba <hoijui.quaero@gmail.com>
#
# SPDX-License-Identifier: Unlicense
name: Publish Docker image
on:
push:
branches: [ master ]
paths:
- 'Dockerfile'
- 'run/*'
- '.github/workflows/docker.yml'
tags:
- 'v?[0-9]+.[0-9]+.[0-9]+'
# release:
# types: [published]
jobs:
publish_docker_images:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Generating build/Dockerfile_REPLACED
# ... by fetching latest Nim and Git versions,
# and injecting them into Dockerfile
run: |
run/inject-dockerfile
echo "############################################################"
cat build/Dockerfile_REPLACED
echo "############################################################"
- name: Generate Docker meta-info
id: meta
uses: docker/metadata-action@v3
with:
images: hoijui/nim-ci
tags: |
type=raw,value=latest,enable=${{ endsWith(github.ref, 'master') }}
type=match,value=latest,pattern=v?([0-9]+.[0-9]+.[0-9]+),group=1
type=ref,event=branch
type=ref,event=tag
type=sha
flavor: |
latest=false
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
# So now you can use Actions' own caching!
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push to DockerHub
uses: docker/build-push-action@v2
with:
file: build/Dockerfile_REPLACED
context: .
pull: true
push: ${{ github.event_name != 'pull_request' }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# This ugly bit is necessary if you don't want your cache to grow forever
# till it hits GitHub's limit of 5GB.
# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: Move cache (HACK)
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache