-
Notifications
You must be signed in to change notification settings - Fork 0
95 lines (84 loc) · 2.55 KB
/
docker.yaml
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
name: Build docker image
on:
workflow_call:
secrets:
DOCKERHUB_USERNAME:
description: 'Your Docker Hub username'
required: false
DOCKERHUB_TOKEN:
description: 'Your token for Docker Hub'
required: false
inputs:
artifact:
type: string
default: build
description: Name of the artifact to download & build
tags:
required: true
type: string
description: Tags for docker image
platforms:
type: string
default: linux/amd64
description: Platforms for docker image
dockerfile:
type: string
default: ./.docker/neos/Dockerfile
description: Dockerfile to use
jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: all
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
id: buildx
with:
install: true
- name: Login to Github Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to Docker Hub Registry
env:
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
if: ${{ env.dockerhub_username }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Checkout repository
uses: actions/checkout@v4
if: ${{ inputs.artifact == '' }}
- name: Download artifact
uses: actions/download-artifact@v4
if: ${{ inputs.artifact != '' }}
with:
name: ${{ inputs.artifact }}
- name: Unpack artifact
if: ${{ inputs.artifact != '' }}
run: tar -vxf ${{ inputs.artifact }}.tar
- name: Remove downloaded tar file
if: ${{ inputs.artifact != '' }}
run: rm ${{ inputs.artifact }}.tar || true
- name: Build Image
uses: docker/build-push-action@v6
with:
context: .
file: ${{ inputs.dockerfile }}
push: true
tags: ${{ inputs.tags }}
platforms: ${{ inputs.platforms }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Delete artifact
if: ${{ inputs.artifact != '' }}
uses: geekyeggo/delete-artifact@v5
with:
name: ${{ inputs.artifact }}
failOnError: false