Deploy to prod #2
This file contains hidden or 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 ${{ inputs.environment }} | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| environment: | |
| description: 'Environment to run deploy' | |
| type: environment | |
| required: true | |
| default: staging | |
| image-tag: | |
| description: Image tag (Optional, only used for existing images) | |
| type: string | |
| default: '' | |
| jobs: | |
| build-docker-image: | |
| name: BuildDockerImage | |
| runs-on: ubuntu-latest | |
| environment: ${{ inputs.environment }} | |
| if: ${{ !inputs.image-tag }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 1 | |
| - 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: Build and Push Universer Image | |
| run: | | |
| IMAGE_TAG=$(echo "${{ github.sha }}" | cut -c 1-7) | |
| make push_image IMAGE_TAG=$IMAGE_TAG CR=${{ env.CR }} | |
| deploy-k8s: | |
| name: DeployK8s | |
| runs-on: arc-runner-set | |
| needs: build-docker-image | |
| environment: ${{ 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(inputs.environment, 'feature') }} | |
| run: echo "FEATURE=$(echo ${GITHUB_REF#refs/heads/feat/})" >> $GITHUB_ENV | |
| - uses: peter-evans/repository-dispatch@v2 | |
| with: | |
| token: ${{ secrets.GH_ACCESS_TOKEN }} | |
| repository: dream-num/helm-chart-private | |
| event-type: ${{ vars.DISPATCH_EVENT_TYPE }} | |
| client-payload: '{"service":"${{ inputs.service }}","tag":"${{ env.IMAGE_TAG }}","feature":"${{ env.FEATURE }}"}' | |
| deploy-manual: | |
| name: DeployK8s | |
| runs-on: arc-runner-set | |
| environment: ${{ inputs.environment }} | |
| if: ${{ inputs.image-tag }} | |
| steps: | |
| - name: Set IMAGE_TAG environment variable | |
| run: echo "IMAGE_TAG=${{ inputs.image-tag }}" >> $GITHUB_ENV | |
| - name: Set FEATURE environment variable | |
| if: ${{ startsWith(inputs.environment, 'feature') }} | |
| run: echo "FEATURE=$(echo ${GITHUB_REF#refs/heads/feat/})" >> $GITHUB_ENV | |
| - uses: peter-evans/repository-dispatch@v2 | |
| with: | |
| token: ${{ secrets.GH_ACCESS_TOKEN }} | |
| repository: dream-num/helm-chart-private | |
| event-type: ${{ vars.DISPATCH_EVENT_TYPE }} | |
| client-payload: '{"service":"${{ inputs.service }}","tag":"${{ env.IMAGE_TAG }}","feature":"${{ env.FEATURE }}"}' |