Skip to content

Deploy docs to international #260

Deploy docs to international

Deploy docs to international #260

Workflow file for this run

name: ⬆️ Deploy
run-name: Deploy ${{ inputs.univer-docs-site && 'docs' || '' }} to ${{ github.event_name == 'schedule' && 'staging' || inputs.environment }}
on:
workflow_dispatch:
inputs:
environment:
description: Environment to deploy
required: true
default: staging
type: environment
univer-docs-site:
description: Deploy univer-docs-site
type: boolean
default: true
image-tag:
description: Image tag (Optional, only used for existing images)
type: string
default: ''
runner-name:
description: The name of the runner
type: choice
default: large-runner
options:
- github-runner
- large-runner
- shenzhen
acr-region:
description: ACR registry
type: choice
default: shenzhen
options:
- cn-shenzhen
- us-east-1
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build-docker-image:
if: ${{ github.event_name == 'workflow_dispatch' && (inputs.univer-docs-site) && !inputs.image-tag }}
name: Build ${{ inputs.univer-docs-site && 'docs' || '' }} Docker Image
runs-on: ${{ inputs.runner-name == 'github-runner' && 'ubuntu-latest' || inputs.runner-name || 'ubuntu-latest' }}
timeout-minutes: 30
environment: ${{ github.event_name == 'schedule' && 'staging' || inputs.environment }}
env:
NPM_REGISTRY: ''
CR: univer-acr-registry.cn-shenzhen.cr.aliyuncs.com
ACR_REGION: ${{ inputs.acr-region }}
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_TOKEN }}
submodules: true
persist-credentials: false
- uses: ./.github/actions/setup-docker
id: setup-docker
with:
runner-name: ${{ inputs.runner-name }}
environment: ${{ inputs.environment }}
- if: ${{ inputs.runner-name == 'shenzhen' }}
run: |
echo "NPM_REGISTRY=https://registry.npmmirror.com" >> $GITHUB_ENV
- name: Build and Push Docker Image
env:
EVENT_NAME: ${{ github.event_name }}
UNIVER_DOCS_SITE: ${{ inputs.univer-docs-site }}
BUILDER_NAME: ${{ steps.setup-docker.outputs.builder-name }}
PUSH_TAG_AS_LATEST: ${{ vars.PUSH_TAG_AS_LATEST }}
CR: ${{ env.CR }}
NPM_REGISTRY: ${{ env.NPM_REGISTRY }}
NEXT_PUBLIC_DOCS_SOURCE_REF: ${{ github.ref_name }}
NEXT_POSTHOG_APIKEY: ${{ secrets.NEXT_POSTHOG_APIKEY }}
run: |
IMAGE_TAG=$(echo "$GITHUB_SHA" | cut -c 1-7)
if [ "$EVENT_NAME" == "schedule" ] || [ "$UNIVER_DOCS_SITE" == "true" ]; then
make push_image REPOSITORY=univer-docs-site \
PUSH_TAG="$IMAGE_TAG" \
BUILDER="$BUILDER_NAME" \
OSARCH=linux/amd64 \
PUSH_TAG_AS_LATEST="$PUSH_TAG_AS_LATEST" \
CR="$CR" NPM_REGISTRY="$NPM_REGISTRY" \
NEXT_PUBLIC_DOCS_SOURCE_REF="$NEXT_PUBLIC_DOCS_SOURCE_REF" \
NEXT_POSTHOG_APIKEY="$NEXT_POSTHOG_APIKEY"
fi
deploy-site:
if: ${{ inputs.univer-docs-site }}
name: Deploy Site
needs: [build-docker-image]
runs-on: arc-runner-set
environment: ${{ github.event_name == 'schedule' && 'staging' || inputs.environment }}
steps:
- name: Set IMAGE_TAG environment variable
env:
IMAGE_TAG_INPUT: ${{ inputs.image-tag }}
run: |
if [ -z "$IMAGE_TAG_INPUT" ]; then
echo "IMAGE_TAG=$(echo "$GITHUB_SHA" | cut -c 1-7)" >> "$GITHUB_ENV"
else
echo "IMAGE_TAG=$IMAGE_TAG_INPUT" >> "$GITHUB_ENV"
fi
- name: Set FEATURE environment variable
if: ${{ startsWith(github.event_name == 'schedule' && 'staging' || inputs.environment, 'feature') }}
run: echo "FEATURE=$(echo "${GITHUB_REF#refs/heads/feat/}")" >> "$GITHUB_ENV"
- uses: peter-evans/repository-dispatch@v2
name: Deploy Docs Site
if: ${{ github.event_name == 'schedule' || inputs.univer-docs-site }}
with:
token: ${{ secrets.GH_TOKEN }}
repository: dream-num/helm-chart-private
event-type: ${{ vars.DISPATCH_EVENT_TYPE }}
client-payload: >
{
"service": "univer-docs-site",
"tag": "${{ env.IMAGE_TAG }}",
"feature": "${{ env.FEATURE }}",
"registry":"${{ env.CR }}"
}
deploy-k8s:
name: DeployK8s
if: ${{ github.event_name == 'workflow_dispatch' && inputs.image-tag }}
runs-on: arc-runner-set
environment: ${{ github.event_name == 'schedule' && 'staging' || inputs.environment }}
steps:
- name: Set IMAGE_TAG environment variable
env:
IMAGE_TAG_INPUT: ${{ inputs.image-tag }}
run: |
if [ -z "$IMAGE_TAG_INPUT" ]; then
echo "IMAGE_TAG=$(echo "$GITHUB_SHA" | cut -c 1-7)" >> "$GITHUB_ENV"
else
echo "IMAGE_TAG=$IMAGE_TAG_INPUT" >> "$GITHUB_ENV"
fi
- name: Set FEATURE environment variable
if: ${{ startsWith(github.event_name == 'schedule' && 'staging' || inputs.environment, 'feature') }}
run: echo "FEATURE=$(echo "${GITHUB_REF#refs/heads/feat/}")" >> "$GITHUB_ENV"
- name: Set US ACR region
if: ${{ inputs.acr-region == 'us-east-1' || inputs.environment == 'prod' || inputs.environment == 'feature prod' }}
run: |
echo "CR=univer-acr-eastus-registry.us-east-1.cr.aliyuncs.com" >> "$GITHUB_ENV"
- uses: peter-evans/repository-dispatch@v2
name: Deploy Docs Site
if: ${{ github.event_name == 'schedule' || inputs.univer-docs-site }}
with:
token: ${{ secrets.GH_TOKEN }}
repository: dream-num/helm-chart-private
event-type: ${{ vars.DISPATCH_EVENT_TYPE }}
client-payload: >
{
"service": "univer-docs-site",
"tag": "${{ env.IMAGE_TAG }}",
"feature": "${{ env.FEATURE }}",
"registry":"${{ env.CR }}"
}