-
Notifications
You must be signed in to change notification settings - Fork 59
214 lines (198 loc) · 12.6 KB
/
container.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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
name: Build a container
on:
workflow_call:
inputs:
tachidesk_release_type:
required: true
default: 'preview'
description: 'Suwayomi Release Type'
type: string
do_upload:
required: true
default: true
description: 'Should the image be uploaded to the registry?'
type: boolean
secrets:
DISCORD_TACHIDESK_WEBHOOK_ID:
required: false
DISCORD_TACHIDESK_TOKEN:
required: false
env:
server_repo: ${{ inputs.tachidesk_release_type == 'stable' && 'Suwayomi-Server' || 'Suwayomi-Server-preview' }}
test_image_tag: ghcr.io/suwayomi/tachidesk-test:testing
this_actions_run_url: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
jobs:
build_the_container:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# We want a full clone of the repo so that the rev-list count below is correct
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Get latest release metadata
id: get_latest_release_metadata
run: |
curl -s https://api.github.com/repos/suwayomi/${{ env.server_repo }}/releases/latest > ${{ runner.temp }}/latest_release.json
release_url=$(jq -r '.assets[] | select(.content_type == "application/java-archive") | .browser_download_url' ${{ runner.temp }}/latest_release.json)
release_tag=$(jq -r '.tag_name' ${{ runner.temp }}/latest_release.json)
release_filename=$(basename $release_url)
tachidesk_docker_git_commit=$(git rev-list --count HEAD)
build_date=$(date "+%F")
echo "release_url=$release_url" >> $GITHUB_OUTPUT
echo "release_tag=$release_tag" >> $GITHUB_OUTPUT
echo "release_filename=$release_filename" >> $GITHUB_OUTPUT
echo "tachidesk_docker_git_commit=$tachidesk_docker_git_commit" >> $GITHUB_OUTPUT
echo "build_date=$build_date" >> $GITHUB_OUTPUT
# this only builds the amd64 version of the image, which is fine as that's
# all that is needed to test the container on GitHub Actions' build servers (which are running amd64 CPUs)
- name: Build container image to test
uses: docker/build-push-action@v6
with:
load: true # this is important, as this tells build-push-action to save the container to the local docker daemon
build-args: |
BUILD_DATE=${{ steps.get_latest_release_metadata.outputs.build_date }}
TACHIDESK_RELEASE_TAG=${{ steps.get_latest_release_metadata.outputs.release_tag }}
TACHIDESK_RELEASE_DOWNLOAD_URL=${{ steps.get_latest_release_metadata.outputs.release_url }}
TACHIDESK_FILENAME=${{ steps.get_latest_release_metadata.outputs.release_filename }}
TACHIDESK_DOCKER_GIT_COMMIT=${{ steps.get_latest_release_metadata.outputs.tachidesk_docker_git_commit }}
tags: ${{ env.test_image_tag }}
# Launch the container and then hit the 'about' API to verify that it can start up correctly.
- name: Test new container image without passing environment variables
env:
DO_UPLOAD: ${{ inputs.do_upload }}
run: |
mkdir -p ${{ runner.temp }}/tachidesk
chmod -R 777 ${{ runner.temp }}/tachidesk
docker run -d -p 127.0.0.1:4568:4567 -v ${{ runner.temp }}/tachidesk:/home/suwayomi/.local/share/Tachidesk --name=suwayomi_test ${{ env.test_image_tag }}
sleep 15
curl -s 127.0.0.1:4568/api/v1/settings/about/ && val=$(curl -s 127.0.0.1:4568/api/v1/settings/about/ | grep -o "Suwayomi-Server" | sort --unique)
docker stop suwayomi_test
docker logs suwayomi_test > ${{ runner.temp }}/tachidesk.log
docker rm suwayomi_test
if [[ $val != "Suwayomi-Server" ]]; then
echo "Container logs:"
echo "=============================="
cat ${{ runner.temp }}/tachidesk.log
echo "=============================="
echo "Did not find Suwayomi-Server in server response: ${val}"
if [[ $DO_UPLOAD == "true" ]]; then
curl \
-F 'payload_json={"username": "Github", "content": "<@855022649926221854>\nDocker ${{ inputs.tachidesk_release_type }} image dry run failed! 😢 Version - ${{ steps.get_latest_release_metadata.outputs.release_tag }}. [See the full run log](${{ env.this_actions_run_url }})"}' \
-F "file1=@${{ runner.temp }}/tachidesk.log" \
"https://discord.com/api/webhooks/${{ secrets.DISCORD_TACHIDESK_WEBHOOK_ID }}/${{ secrets.DISCORD_TACHIDESK_TOKEN }}"
fi
exit 1
fi
- name: Test new container image with passing environment variables
env:
DO_UPLOAD: ${{ inputs.do_upload }}
run: |
mkdir -p ${{ runner.temp }}/tachidesk_env_vars
chmod -R 777 ${{ runner.temp }}/tachidesk_env_vars
docker run -d -p 127.0.0.1:4568:4567 -v ${{ runner.temp }}/tachidesk_env_vars:/home/suwayomi/.local/share/Tachidesk \
-e BIND_IP=0.0.0.0 \
-e BIND_PORT=4567 \
-e SOCKS_PROXY_ENABLED=false \
-e SOCKS_PROXY_HOST=socks_host \
-e SOCKS_PROXY_PORT=socks_port \
-e WEB_UI_ENABLED=true \
-e WEB_UI_FLAVOR=WebUI \
-e WEB_UI_CHANNEL=preview \
-e WEB_UI_UPDATE_INTERVAL=2 \
-e DOWNLOAD_AS_CBZ=true \
-e AUTO_DOWNLOAD_CHAPTERS=true \
-e AUTO_DOWNLOAD_EXCLUDE_UNREAD=false \
-e AUTO_DOWNLOAD_NEW_CHAPTERS_LIMIT=5 \
-e AUTO_DOWNLOAD_IGNORE_REUPLOADS=false \
-e EXTENSION_REPOS=[\"http://github.com/orginazation-name/repo-name\",\"http://github.com/orginazation-name-2/repo-name-2\"] \
-e MAX_SOURCES_IN_PARALLEL=12 \
-e UPDATE_EXCLUDE_UNREAD=false \
-e UPDATE_EXCLUDE_STARTED=false \
-e UPDATE_EXCLUDE_COMPLETED=false \
-e UPDATE_INTERVAL=30 \
-e UPDATE_MANGA_INFO=true \
-e BASIC_AUTH_ENABLED=true \
-e BASIC_AUTH_USERNAME=manga \
-e BASIC_AUTH_PASSWORD=hello123 \
-e DEBUG=true \
-e BACKUP_TIME=13:37 \
-e BACKUP_INTERVAL=2 \
-e BACKUP_TTL=31 \
-e FLARESOLVERR_ENABLED=true \
-e FLARESOLVERR_URL=http://flaresolverr:8191 \
-e FLARESOLVERR_TIMEOUT=30 \
-e FLARESOLVERR_SESSION_NAME=session-name \
-e FLARESOLVERR_SESSION_TTL=120 \
--name=suwayomi_test \
${{ env.test_image_tag }}
sleep 15
curl -s http://manga:[email protected]:4568/api/v1/settings/about/ && val_env_vars=$(curl -s http://manga:[email protected]:4568/api/v1/settings/about/ | grep -o "Suwayomi-Server" | sort --unique)
docker stop suwayomi_test
docker logs suwayomi_test > ${{ runner.temp }}/tachidesk_env_vars.log
docker rm suwayomi_test
if [[ $val_env_vars != "Suwayomi-Server" ]]; then
echo "Container logs:"
echo "=============================="
cat ${{ runner.temp }}/tachidesk_env_vars.log
echo "=============================="
echo "Did not find Suwayomi-Server in server response: ${val_env_vars}"
if [[ $DO_UPLOAD == "true" ]]; then
curl \
-F 'payload_json={"username": "Github", "content": "<@855022649926221854>\nDocker ${{ inputs.tachidesk_release_type }} image dry run failed! 😢 Version - ${{ steps.get_latest_release_metadata.outputs.release_tag }}. [See the full run log](${{ env.this_actions_run_url }})"}' \
-F "file1=@${{ runner.temp }}/tachidesk_env_vars.log" \
"https://discord.com/api/webhooks/${{ secrets.DISCORD_TACHIDESK_WEBHOOK_ID }}/${{ secrets.DISCORD_TACHIDESK_TOKEN }}"
fi
exit 1
fi
# Now we build for all the platforms we support here. NB: the amd64
# won't be rebuilt since the local docker daemon has that still cached
- name: Push container image to registry
if: inputs.do_upload
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64/v8,linux/ppc64le,linux/s390x,linux/riscv64
push: true
build-args: |
BUILD_DATE=${{ steps.get_latest_release_metadata.outputs.build_date }}
TACHIDESK_RELEASE_TAG=${{ steps.get_latest_release_metadata.outputs.release_tag }}
TACHIDESK_RELEASE_DOWNLOAD_URL=${{ steps.get_latest_release_metadata.outputs.release_url }}
TACHIDESK_FILENAME=${{ steps.get_latest_release_metadata.outputs.release_filename }}
TACHIDESK_DOCKER_GIT_COMMIT=${{ steps.get_latest_release_metadata.outputs.tachidesk_docker_git_commit }}
tags: |
${{ inputs.tachidesk_release_type == 'stable' && 'ghcr.io/suwayomi/tachidesk:latest' || '' }}
ghcr.io/suwayomi/tachidesk:${{ inputs.tachidesk_release_type }}
ghcr.io/suwayomi/tachidesk:${{ steps.get_latest_release_metadata.outputs.release_tag }}
# - name: Create slim container
# uses: kitabisa/docker-slim-action@v1
# env:
# DSLIM_HTTP_PROBE: false
# DSLIM_PRESERVE_PATH: /opt/java/openjdk/lib,/opt/java/openjdk/conf,/home/suwayomi/.local/share/Tachidesk
# with:
# target: ghcr.io/suwayomi/tachidesk:${{ inputs.tachidesk_release_type }}
# tag: '${{ inputs.tachidesk_release_type }}-slim'
# - name: Tag slim container and push registery to repository
# run: |
# docker tag ghcr.io/suwayomi/tachidesk:${{ inputs.tachidesk_release_type }}-slim ghcr.io/suwayomi/tachidesk:${{ steps.get_latest_release_metadata.outputs.release_tag }}-slim
# if [ "${{ inputs.tachidesk_release_type }}" == "stable" ]; then
# docker tag ghcr.io/suwayomi/tachidesk:${{ inputs.tachidesk_release_type }}-slim ghcr.io/suwayomi/tachidesk:latest-slim
# fi
# docker image push "ghcr.io/suwayomi/tachidesk" --all-tags
- name: Send a Discord message through the webhook (preview build)
if: inputs.do_upload && inputs.tachidesk_release_type == 'preview'
run: |
curl -H "Content-Type: application/json" -d '{"content": "Docker Preview Image Published!","embeds":[{"color":16729344,"author":{"name":"${{ github.repository_owner }}","icon_url":"https://avatars.githubusercontent.com/u/81182076","url":"https://github.com/${{ github.repository_owner }}"},"title":"Docker Preview Release","url":"https://github.com/${{ github.repository_owner }}/docker-tachidesk","fields":[{"name":"docker update","value":"docker pull ghcr.io/suwayomi/tachidesk:preview","inline":false},{"name":"docker run","value":"docker run -p 4567:4567 ghcr.io/suwayomi/tachidesk:preview","inline":false}],"thumbnail":{"url": "https://www.docker.com/sites/default/files/d8/2019-07/vertical-logo-monochromatic.png"},"description":"Tachidesk version - ${{ steps.get_latest_release_metadata.outputs.release_tag }}"}]}' "https://discord.com/api/webhooks/${{ secrets.DISCORD_TACHIDESK_WEBHOOK_ID }}/${{ secrets.DISCORD_TACHIDESK_TOKEN }}"
- name: Send a Discord message through the webhook (stable build)
if: inputs.do_upload && inputs.tachidesk_release_type == 'stable'
run: |
curl -H "Content-Type: application/json" -d '{"content": "Docker Stable Image Published!","embeds":[{"color":5409028,"author":{"name":"${{ github.repository_owner }}","icon_url":"https://avatars.githubusercontent.com/u/81182076","url":"https://github.com/${{ github.repository_owner }}"},"title":"Docker Stable Release","url":"https://github.com/${{ github.repository_owner }}/docker-tachidesk","fields":[{"name":"docker update","value":"docker pull ghcr.io/suwayomi/tachidesk:stable","inline":false},{"name":"docker run","value":"docker run -p 4567:4567 ghcr.io/suwayomi/tachidesk","inline":false}],"thumbnail":{"url": "https://www.docker.com/sites/default/files/d8/2019-07/vertical-logo-monochromatic.png"},"description":"Tachidesk version - ${{ steps.get_latest_release_metadata.outputs.release_tag }}"}]}' "https://discord.com/api/webhooks/${{ secrets.DISCORD_TACHIDESK_WEBHOOK_ID }}/${{ secrets.DISCORD_TACHIDESK_TOKEN }}"