-
-
Notifications
You must be signed in to change notification settings - Fork 47
133 lines (116 loc) · 3.67 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
name: Docker
on:
push:
branches:
- master
- next
tags:
- v*
pull_request:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
include:
- context: ./back
dockerfile: Dockerfile
label: back
image: zoriya/kyoo_back
- context: ./back
dockerfile: Dockerfile.migrations
label: migrations
image: zoriya/kyoo_migrations
- context: ./api
dockerfile: Dockerfile
label: api
image: zoriya/kyoo_api
- context: ./front
dockerfile: Dockerfile
label: front
image: zoriya/kyoo_front
- context: ./scanner
dockerfile: Dockerfile
label: scanner
image: zoriya/kyoo_scanner
- context: ./autosync
dockerfile: Dockerfile
label: autosync
image: zoriya/kyoo_autosync
- context: ./transcoder
dockerfile: Dockerfile
label: transcoder
image: zoriya/kyoo_transcoder
- context: ./auth
dockerfile: Dockerfile
label: auth
image: zoriya/keibi
name: Build ${{matrix.label}}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
should_run:
- '${{matrix.context}}/**'
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
docker.io/${{matrix.image}}
ghcr.io/${{matrix.image}}
tags: |
type=edge
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Check if a package should be pushed
run: |
echo "SHOULD_PUSH=$([ "${GITHUB_REF##*/}" == "master" ] || [ "${GITHUB_REF##*/}" == "next" ] || [ "${GITHUB_REF_TYPE}" == "tag" ] && echo "true" || echo "false")" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
if: env.SHOULD_PUSH == 'true'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to GitHub Container Registry
if: env.SHOULD_PUSH == 'true'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v6
if: steps.filter.outputs.should_run == 'true' || github.event_name == 'workflow_dispatch' || startsWith(github.event.ref, 'refs/tags/v')
with:
context: ${{matrix.context}}
file: ${{matrix.context}}/${{matrix.dockerfile}}
platforms: linux/amd64,linux/arm64
build-args: |
VERSION=0.0.0
push: ${{env.SHOULD_PUSH}}
tags: ${{steps.meta.outputs.tags}}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Sync README.MD
if: env.SHOULD_PUSH == 'true'
uses: ms-jpq/sync-dockerhub-readme@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: ${{ matrix.image }}
readme: "./README.md"