Deploy to staging #296
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: ⚓ Push | |
run-name: Deploy to ${{ github.event_name == 'schedule' && 'staging' || inputs.environment }} | |
on: | |
workflow_dispatch: | |
inputs: | |
environment: | |
description: Environment to deploy | |
required: true | |
default: staging | |
type: environment | |
univer-site: | |
description: Deploy univer-site | |
type: boolean | |
default: true | |
univer-docs-site: | |
description: Deploy univer-docs-site | |
type: boolean | |
default: true | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build-docker-image: | |
name: Build Docker Image | |
runs-on: ubuntu-latest | |
timeout-minutes: 30 | |
environment: ${{ github.event_name == 'schedule' && 'staging' || inputs.environment }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.GH_TOKEN }} | |
submodules: true | |
- name: Login to Aliyun Container Registry (ACR) | |
uses: aliyun/acr-login@v1 | |
with: | |
login-server: univer-acr-registry.cn-shenzhen.cr.aliyuncs.com | |
region-id: cn-shenzhen | |
username: '${{ secrets.REGISTRY_USERNAME }}' | |
password: '${{ secrets.REGISTRY_PASSWORD }}' | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
id: buildx | |
with: | |
driver-opts: | | |
image=${{ secrets.REGISTRY_CR }}/devops/buildkit:buildx-stable-1 | |
- name: Build and Push Docker Image | |
run: | | |
IMAGE_TAG=$(echo "${{ github.sha }}" | cut -c 1-7) | |
cd packages | |
if [ "${{ github.event_name }}" == "schedule" ] || [ "${{ inputs.univer-site }}" == "true" ]; then | |
cd www | |
make push_image PUSH_TAG=$IMAGE_TAG BUILDER=${{ steps.buildx.outputs.name }} OSARCH=linux/amd64 PUSH_TAG_AS_LATEST=${{ vars.PUSH_TAG_AS_LATEST }} CR=${{ secrets.REGISTRY_CR }} | |
cd .. | |
fi | |
if [ "${{ github.event_name }}" == "schedule" ] || [ "${{ inputs.univer-docs-site }}" == "true" ]; then | |
cd docs | |
make push_image PUSH_TAG=$IMAGE_TAG BUILDER=${{ steps.buildx.outputs.name }} OSARCH=linux/amd64 PUSH_TAG_AS_LATEST=${{ vars.PUSH_TAG_AS_LATEST }} CR=${{ secrets.REGISTRY_CR }} | |
cd .. | |
fi | |
deploy-k8s: | |
name: DeployK8s | |
needs: build-docker-image | |
runs-on: arc-runner-set | |
environment: ${{ github.event_name == 'schedule' && 'staging' || inputs.environment }} | |
steps: | |
- name: Set IMAGE_TAG environment variable | |
run: echo "IMAGE_TAG=$(echo ${{ github.sha }} | cut -c 1-7)" >> $GITHUB_ENV | |
- 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 | |
if: ${{ github.event_name == 'schedule' || inputs.univer-site }} | |
with: | |
token: ${{ secrets.GH_TOKEN }} | |
repository: dream-num/helm-chart-private | |
event-type: ${{ vars.DISPATCH_EVENT_TYPE }} | |
client-payload: > | |
{ | |
"service": "univer-site", | |
"tag": "${{ env.IMAGE_TAG }}", | |
"feature": "${{ env.FEATURE }}" | |
} | |
- uses: peter-evans/repository-dispatch@v2 | |
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 }}" | |
} |