-
Notifications
You must be signed in to change notification settings - Fork 0
161 lines (152 loc) · 5.06 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
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
name: Build PHP FPM Container and Upload to Dockerhub
on:
workflow_call:
secrets:
DockerHubUser:
required: true
DockerHubPass:
required: true
ComposerAuth:
required: false
SentryToken:
required: false
SentryOrg:
required: false
jobs:
main:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Docker Login
uses: docker/login-action@v2
with:
username: ${{ secrets.DockerHubUser }}
password: ${{ secrets.DockerHubPass }}
######################################################
# Setting up final build tags
######################################################
- name: Prepare Tags
id: prep
run: |
IMAGE=elbgoodsgmbh/${GITHUB_REPOSITORY#*/}
echo ::set-output name=image::${IMAGE}
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ steps.prep.outputs.image }}
flavor: |
latest=auto
tags: |
type=edge,enable=true,branch=main
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }}
######################################################
# Setup Cache and BuildX
######################################################
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
with:
driver-opts: network=host
######################################################
# Build!
######################################################
- name: Build and push
id: docker_build
uses: docker/build-push-action@v4
with:
cache-from: "type=gha"
cache-to: "type=gha,mode=max"
builder: ${{ steps.buildx.outputs.name }}
file: ./Dockerfile
target: production
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
COMPOSER_AUTH=${{ secrets.ComposerAuth }}
local:
runs-on: self-hosted
if: github.ref_name == 'main'
needs: main
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Docker Login
uses: docker/login-action@v1
with:
username: ${{ secrets.DockerHubUser }}
password: ${{ secrets.DockerHubPass }}
######################################################
# Setting up final build tags
######################################################
- name: Prepare Tags
id: prep
run: |
IMAGE=elbgoodsgmbh/${GITHUB_REPOSITORY#*/}
echo ::set-output name=image::${IMAGE}
######################################################
# Setup Cache and BuildX
######################################################
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: arm64
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
with:
driver-opts: network=host
- name: Available platforms
run: echo ${{ steps.buildx.outputs.platforms }}
######################################################
# Build!
######################################################
- name: Build and push local
id: docker_build_local
uses: docker/build-push-action@v2
with:
cache-from: "type=gha"
cache-to: "type=gha,mode=max"
builder: ${{ steps.buildx.outputs.name }}
file: ./Dockerfile
target: local
push: true
tags: ${{ steps.prep.outputs.image }}:local
platforms: linux/amd64,linux/arm64
build-args: |
COMPOSER_AUTH=${{ secrets.ComposerAuth }}
check-org:
runs-on: ubuntu-latest
outputs:
check-org: ${{ steps.check-org.outputs.defined }}
steps:
- id: check-org
if: "${{ env.SentryOrg != '' }}"
run: echo "::set-output name=defined::true"
env:
SentryOrg: ${{ secrets.SentryOrg }}
publish-sentry:
runs-on: ubuntu-latest
needs: [check-org]
if: ${{ ( github.event_name == 'release' || github.event.action == 'created' ) && needs.check-org.outputs.check-org == 'true' }}
steps:
- uses: actions/checkout@v2
- name: Prepare Project
id: project
run: |
PROJECT=${GITHUB_REPOSITORY#*/}
echo ::set-output name=project::${PROJECT}
- name: Notify Sentry of new Release
uses: getsentry/action-release@v1
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SentryToken }}
SENTRY_ORG: ${{ secrets.SentryOrg }}
SENTRY_PROJECT: ${{ steps.project.outputs.project }}
with:
set_commits: skip
version: ${{ github.ref }}