mirror of
https://github.com/AppFlowy-IO/AppFlowy-Web.git
synced 2025-12-19 01:47:11 +08:00
152 lines
6.1 KiB
YAML
152 lines
6.1 KiB
YAML
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 |