-
Notifications
You must be signed in to change notification settings - Fork 27
132 lines (120 loc) · 4.81 KB
/
call_build_push.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
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
123
124
125
126
127
128
129
130
131
132
---
name: Build and Push
on:
workflow_call:
inputs:
flavor:
description: "Set the base image [base, slim or alpine]"
default: "base"
required: false
type: string
version:
description: "EteBase Version"
required: true
type: string
platforms:
description: "Set the platforms to build [ linux/amd64 and/or linux/arm64 ]"
default: "linux/amd64,linux/arm64"
required: false
type: string
tag:
description: "Tag"
required: false
type: string
pushit:
description: "Should push?"
default: false
required: false
type: boolean
secrets:
dckr_username:
required: true
dckr_token:
required: true
jobs:
build-n-push:
runs-on: ubuntu-latest
steps:
- name: Checkout Dockerfiles and Context
uses: actions/checkout@v4
- id: prepare
name: Process Inputs
uses: ./.github/actions/process-inputs
with:
ete_version: ${{ inputs.version }}
flavor: ${{ inputs.flavor }}
- id: docker_metadata
name: Prepare Docker Metadata
uses: docker/[email protected]
with:
labels: |
maintainer=${{ github.repository_owner }}
version=${{ steps.prepare.outputs.source_ref }}+eb.${{ steps.prepare.outputs.ete_num_version }}+py.${{ steps.prepare.outputs.py_version }}
org.opencontainers.image.authors=Victor R. Santos <[email protected]>
org.opencontainers.image.title=Docker Etebase Server
org.opencontainers.image.source=${{ github.repositoryUrl }}
org.opencontainers.image.version=${{ steps.prepare.outputs.ete_version }}
org.opencontainers.image.base.name=docker.io/library/${{ steps.prepare.outputs.py_image }}
org.opencontainers.image.url=https://hub.docker.com/r/${{ secrets.dckr_username }}/etebase
images: |
${{ secrets.dckr_username }}/etebase
${{ secrets.dckr_username }}/etesync
flavor: |
latest=${{ ( inputs.flavor == 'base' && steps.prepare.outputs.is_semver == 'true' ) }}
suffix=${{ steps.prepare.outputs.suffix }}
tags: |
type=edge,enable=${{ inputs.tag != '' || steps.prepare.outputs.is_semver == 'false' }}
type=raw,value=${{ inputs.tag }},enable=${{ inputs.tag != '' }}
type=raw,value=${{ inputs.flavor }},suffix=,enable=${{ inputs.tag == '' && steps.prepare.outputs.is_semver == 'true' }}
type=semver,pattern={{version}},value=${{ steps.prepare.outputs.ete_version }},enable=${{ inputs.tag == '' && steps.prepare.outputs.is_semver == 'true' }}
type=semver,pattern={{major}}.{{minor}},value=${{ steps.prepare.outputs.ete_version }},enable=${{ inputs.tag == '' && steps.prepare.outputs.is_semver == 'true' }}
- id: qemu
name: Set up QEMU
if: contains(inputs.platforms, 'linux/arm')
uses: docker/[email protected]
- id: buildx
name: Set up Docker Buildx
uses: docker/[email protected]
- name: Login to DockerHub
if: inputs.pushit
uses: docker/[email protected]
with:
username: ${{ secrets.dckr_username }}
password: ${{ secrets.dckr_token }}
- id: docker_build_push
name: Docker Build and Push
uses: docker/[email protected]
with:
builder: ${{ steps.buildx.outputs.name }}
platforms: ${{ inputs.platforms }}
context: .
file: ./tags/${{ inputs.flavor }}/Dockerfile
build-args: ETE_VERSION=${{ steps.prepare.outputs.ete_version }}
tags: ${{ steps.docker_metadata.outputs.tags }}
labels: ${{ steps.docker_metadata.outputs.labels }}
push: ${{ inputs.pushit }}
- name: Job Summary
shell: bash
if: ${{ always() }}
run: |
if [ '${{ steps.docker_build_push.conclusion }}' == 'success' ]; then
echo '### Build successful: :white_check_mark:' > summary.md
else
echo '### Build failure: :x:' > summary.md
fi
cat >> summary.md << EOF
Etesync Version: ${{ steps.prepare.outputs.ete_version }}
Image Type: ${{ inputs.flavor }}
Platforms: ${{ inputs.platforms }}
EOF
if [ '${{ steps.docker_build_push.conclusion }}' == 'success' ]; then
cat >> summary.md << EOF
#### Docker:
ImageID: ${{ steps.docker_build_push.outputs.imageid }}
Digest: ${{ steps.docker_build_push.outputs.digest }}
~~~
${{ steps.docker_build_push.outputs.metadata }}
~~~
EOF
fi
cat summary.md >> $GITHUB_STEP_SUMMARY