1- name : Public AppFlowy Web image build and push
1+ name : Build AppFlowy Web Docker Image
2+ 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' || '' }}
3+
24on :
5+ push :
6+ tags :
7+ - ' v*.*.*'
8+ - ' *.*.*'
39 workflow_dispatch :
410 inputs :
5- version :
6- description : ' AppFlowy Web version '
11+ tag_name :
12+ description : ' Tag name for the Docker image (e.g., v1.2.3 or 1.2.3) '
713 required : true
14+ type : string
15+ appflowy_web_branch :
16+ description : ' Branch to build from AppFlowy-Web repo'
17+ required : false
18+ default : ' main'
19+ type : string
20+ build_arm64 :
21+ description : ' Also build ARM64 images (AMD64 always built)'
22+ type : boolean
23+ required : false
24+ default : true
25+ tag_latest :
26+ description : ' Also tag and publish as latest'
27+ type : boolean
28+ required : false
29+ default : true
30+
831env :
9- IMAGE_NAME : ${{ secrets.DOCKER_HUB_USERNAME }}/appflowy_web
32+ LATEST_TAG : latest
33+
1034jobs :
11- build :
12- runs-on : ubuntu-24.04
35+ appflowy_web_image :
36+ runs-on : ${{ matrix.job.os }}
1337 strategy :
14- matrix :
15- platform :
16- - linux/amd64
17- - linux/arm64
18- steps :
19- - name : Prepare
20- run : |
21- PLATFORM=${{ matrix.platform }}
22- VERSION=${{ github.event.inputs.version }}
23- IMAGE_TAG=${VERSION#v}
24- echo "PLATFORM_PAIR=${PLATFORM//\//-}" >> $GITHUB_ENV
25- echo "IMAGE_TAG=${IMAGE_TAG}" >> $GITHUB_ENV
38+ fail-fast : false
39+ matrix :
40+ job : ${{ fromJson((github.event_name == 'workflow_dispatch' && github.event.inputs.build_arm64 == 'true') || 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"}]') }}
41+ env :
42+ IMAGE_NAME : ${{ secrets.DOCKER_HUB_USERNAME }}/appflowy_web
2643
44+ steps :
2745 - name : Check out the repository
28- uses : actions/checkout@v3
46+ uses : actions/checkout@v4
2947 with :
48+ ref : ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.appflowy_web_branch || github.ref }}
3049 fetch-depth : 1
3150
3251 - name : Set up QEMU
3352 uses : docker/setup-qemu-action@v3
3453
54+ - name : Set up Docker Buildx
55+ uses : docker/setup-buildx-action@v3
56+
3557 - name : Log in to Docker Hub
3658 uses : docker/login-action@v3
3759 with :
3860 username : ${{ secrets.DOCKER_HUB_USERNAME }}
3961 password : ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
4062
41- - name : Set up Docker Buildx
42- uses : docker/setup-buildx-action@v3
63+ - name : Get git tag
64+ id : vars
65+ run : |
66+ if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
67+ T="${{ github.event.inputs.tag_name }}"
68+ else
69+ # Extract tag from ref (e.g., refs/tags/v1.2.3 -> v1.2.3)
70+ T="${GITHUB_REF#refs/tags/}"
71+ fi
72+ echo "GIT_TAG=$T" >> $GITHUB_ENV
73+ echo "Tag: $T"
4374
44- - name : Build and push
45- id : build
46- uses : docker/build-push-action@v6
75+ - name : Extract metadata
76+ id : meta
77+ uses : docker/metadata-action@v4
78+ with :
79+ images : registry.hub.docker.com/${{ env.IMAGE_NAME }}
80+
81+ - name : Build and push to appflowy_web
82+ uses : docker/build-push-action@v5
4783 with :
48- platforms : ${{ matrix.platform }}
49- tags : |
50- ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}-${{ env.PLATFORM_PAIR }}
51- ${{ env.IMAGE_NAME }}:latest-${{ env.PLATFORM_PAIR }}
52- build-args : VERSION=${{ github.event.inputs.version }}
5384 context : .
54- file : docker/Dockerfile
55- provenance : false
85+ platforms : ${{ matrix.job.platform }}
86+ file : ./docker/Dockerfile.ssr
5687 push : true
57- merge :
58- runs-on : ubuntu-24.04
59- needs :
60- - build
88+ cache-from : type=gha,scope=appflowy_web-${{ matrix.job.arch }}
89+ cache-to : type=gha,mode=max,scope=appflowy_web-${{ matrix.job.arch }}
90+ tags : |
91+ ${{ env.IMAGE_NAME }}:${{ env.GIT_TAG }}-${{ matrix.job.arch }}
92+ ${{ (github.event_name == 'workflow_dispatch' && github.event.inputs.tag_latest == 'true') || github.event_name == 'push' && format('{0}:{1}-{2}', env.IMAGE_NAME, env.LATEST_TAG, matrix.job.arch) || '' }}
93+ labels : ${{ steps.meta.outputs.labels }}
94+ provenance : false
95+ build-args : |
96+ VERSION=${{ env.GIT_TAG }}
97+
98+ - name : Logout from Docker Hub
99+ if : always()
100+ run : docker logout
101+
102+ appflowy_web_manifest :
103+ runs-on : ubuntu-22.04
104+ needs : [appflowy_web_image]
61105 steps :
62- - name : Prepare
63- run : |
64- VERSION=${{ github.event.inputs.version }}
65- IMAGE_TAG=${VERSION#v}
66- echo "IMAGE_TAG=${IMAGE_TAG}" >> $GITHUB_ENV
67- - name : Login to Docker Hub
106+ - name : Log in to Docker Hub
68107 uses : docker/login-action@v3
69108 with :
70109 username : ${{ secrets.DOCKER_HUB_USERNAME }}
71110 password : ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
72111
73- - name : Set up Docker Buildx
74- uses : docker/setup-buildx-action@v3
112+ - name : Get git tag
113+ id : vars
114+ run : |
115+ if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
116+ T="${{ github.event.inputs.tag_name }}"
117+ else
118+ # Extract tag from ref (e.g., refs/tags/v1.2.3 -> v1.2.3)
119+ T="${GITHUB_REF#refs/tags/}"
120+ fi
121+ echo "GIT_TAG=$T" >> $GITHUB_ENV
122+ echo "Tag: $T"
75123
76- - name : Create and push manifest
124+ - name : Create and push manifest for appflowy_web:version
77125 uses : Noelware/docker-manifest-action@0.4.3
78126 with :
79- inputs : ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}
80- images : ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}-linux- amd64, ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}-linux-arm64
127+ inputs : ${{ secrets.DOCKER_HUB_USERNAME }}/appflowy_web :${{ env.GIT_TAG }}
128+ 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) || '' }}
81129 push : true
82130
83- - name : Create and push manifest
131+ - name : Create and push manifest for appflowy_web:latest
132+ if : ${{ (github.event_name == 'workflow_dispatch' && github.event.inputs.tag_latest == 'true') || github.event_name == 'push' }}
84133 uses : Noelware/docker-manifest-action@0.4.3
85134 with :
86- inputs : ${{ env.IMAGE_NAME }}:latest
87- images : ${{ env.IMAGE_NAME }}:latest-linux-amd64, ${{ env.IMAGE_NAME }}:latest-linux-arm64
135+ inputs : ${{ secrets.DOCKER_HUB_USERNAME }}/appflowy_web:${{ env.LATEST_TAG }}
136+ 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) || '' }}
88137 push : true
138+
139+ - name : Logout from Docker Hub
140+ if : always()
141+ run : docker logout
0 commit comments