forked from AppFlowy-IO/AppFlowy-Web
-
Notifications
You must be signed in to change notification settings - Fork 0
152 lines (136 loc) · 6.1 KB
/
web_docker.yml
File metadata and controls
152 lines (136 loc) · 6.1 KB
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
name: Build AppFlowy Web Docker Image
run-name: Build AppFlowy Web ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag_name || github.ref_name }} ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag_latest == 'true' && 'latest' || github.event_name == 'push' && 'latest' || '' }}
on:
push:
tags:
- 'v*.*.*'
- '*.*.*'
workflow_dispatch:
inputs:
tag_name:
description: 'Tag name for the Docker image (e.g., v1.2.3 or 1.2.3)'
required: true
type: string
appflowy_web_branch:
description: 'Branch to build from AppFlowy-Web repo'
required: false
default: 'main'
type: string
build_arm64:
description: 'Also build ARM64 images (AMD64 always built)'
type: boolean
required: false
default: true
tag_latest:
description: 'Also tag and publish as latest'
type: boolean
required: false
default: true
test:
description: 'If true, append _test to tag and skip latest tag'
type: boolean
required: false
default: false
env:
LATEST_TAG: latest
jobs:
appflowy_web_image:
runs-on: ${{ matrix.job.os }}
strategy:
fail-fast: false
matrix:
job: ${{ fromJson((github.event_name == 'workflow_dispatch' && github.event.inputs.build_arm64 == 'true' && '[{"os":"ubuntu-22.04","platform":"linux/amd64","arch":"amd64"},{"os":"ubuntu-22.04-arm","platform":"linux/arm64","arch":"arm64v8"}]') || (github.event_name == 'push' && '[{"os":"ubuntu-22.04","platform":"linux/amd64","arch":"amd64"},{"os":"ubuntu-22.04-arm","platform":"linux/arm64","arch":"arm64v8"}]') || '[{"os":"ubuntu-22.04","platform":"linux/amd64","arch":"amd64"}]') }}
env:
IMAGE_NAME: ${{ secrets.DOCKER_HUB_USERNAME }}/appflowy_web
steps:
- name: Check out the repository
uses: actions/checkout@v4
with:
ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.appflowy_web_branch || github.ref }}
fetch-depth: 1
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Get git tag
id: vars
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
T="${{ github.event.inputs.tag_name }}"
if [ "${{ github.event.inputs.test }}" == "true" ]; then
T="${T}_test"
fi
else
# Extract tag from ref (e.g., refs/tags/v1.2.3 -> v1.2.3)
T="${GITHUB_REF#refs/tags/}"
fi
echo "GIT_TAG=$T" >> $GITHUB_ENV
echo "Tag: $T"
- name: Extract metadata
id: meta
uses: docker/metadata-action@v4
with:
images: registry.hub.docker.com/${{ env.IMAGE_NAME }}
- name: Build and push to appflowy_web
uses: docker/build-push-action@v5
with:
context: .
platforms: ${{ matrix.job.platform }}
file: ./docker/Dockerfile.ssr
push: true
cache-from: type=gha,scope=appflowy_web-${{ matrix.job.arch }}
cache-to: type=gha,mode=max,scope=appflowy_web-${{ matrix.job.arch }}
tags: |
${{ env.IMAGE_NAME }}:${{ env.GIT_TAG }}-${{ matrix.job.arch }}
${{ (github.event_name == 'workflow_dispatch' && github.event.inputs.tag_latest == 'true' && github.event.inputs.test != 'true') || (github.event_name == 'push' && format('{0}:{1}-{2}', env.IMAGE_NAME, env.LATEST_TAG, matrix.job.arch)) || '' }}
labels: ${{ steps.meta.outputs.labels }}
provenance: false
build-args: |
VERSION=${{ env.GIT_TAG }}
- name: Logout from Docker Hub
if: always()
run: docker logout
appflowy_web_manifest:
runs-on: ubuntu-22.04
needs: [appflowy_web_image]
steps:
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Get git tag
id: vars
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
T="${{ github.event.inputs.tag_name }}"
if [ "${{ github.event.inputs.test }}" == "true" ]; then
T="${T}_test"
fi
else
# Extract tag from ref (e.g., refs/tags/v1.2.3 -> v1.2.3)
T="${GITHUB_REF#refs/tags/}"
fi
echo "GIT_TAG=$T" >> $GITHUB_ENV
echo "Tag: $T"
- name: Create and push manifest for appflowy_web:version
uses: Noelware/docker-manifest-action@0.4.3
with:
inputs: ${{ secrets.DOCKER_HUB_USERNAME }}/appflowy_web:${{ env.GIT_TAG }}
images: ${{ secrets.DOCKER_HUB_USERNAME }}/appflowy_web:${{ env.GIT_TAG }}-amd64${{ ((github.event_name == 'workflow_dispatch' && github.event.inputs.build_arm64 == 'true') || github.event_name == 'push') && format(',{0}/appflowy_web:{1}-arm64v8', secrets.DOCKER_HUB_USERNAME, env.GIT_TAG) || '' }}
push: true
- name: Create and push manifest for appflowy_web:latest
if: ${{ (github.event_name == 'workflow_dispatch' && github.event.inputs.tag_latest == 'true' && github.event.inputs.test != 'true') || (github.event_name == 'push') }}
uses: Noelware/docker-manifest-action@0.4.3
with:
inputs: ${{ secrets.DOCKER_HUB_USERNAME }}/appflowy_web:${{ env.LATEST_TAG }}
images: ${{ secrets.DOCKER_HUB_USERNAME }}/appflowy_web:${{ env.LATEST_TAG }}-amd64${{ ((github.event_name == 'workflow_dispatch' && github.event.inputs.build_arm64 == 'true') || github.event_name == 'push') && format(',{0}/appflowy_web:{1}-arm64v8', secrets.DOCKER_HUB_USERNAME, env.LATEST_TAG) || '' }}
push: true
- name: Logout from Docker Hub
if: always()
run: docker logout