From 1d51a8295e0eb41bb63af13693396280a42243cc Mon Sep 17 00:00:00 2001 From: LongYinan Date: Tue, 31 Oct 2023 16:16:10 +0800 Subject: [PATCH] ci: dynamic setup server deploy environment by release tag --- .github/workflows/deploy.yml | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 01bdefef7e..3751ad7da9 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -198,15 +198,38 @@ jobs: file: .github/deployment/node/Dockerfile tags: ghcr.io/toeverything/affine-graphql:${{env.RELEASE_FLAVOR}}-${{ env.GIT_SHORT_HASH }},ghcr.io/toeverything/affine-graphql:${{env.RELEASE_FLAVOR}} + setup-deploy-environment: + runs-on: ubuntu-latest + name: Setup deploy environment + outputs: + environment: ${{ steps.environment.outputs.value }} + steps: + - uses: actions/checkout@v4 + - name: Setup Node.js + uses: ./.github/actions/setup-node + with: + extra-flags: 'workspaces focus @affine/monorepo' + hard-link-nm: false + electron-install: false + build-infra: false + build-plugins: false + - name: Setup output value + id: environment + run: | + node -e "const env = process.env.flavor ? process.env.flavor : require('semver').parse('${{ github.ref_name }}').prerelease[0] ?? 'stable'; console.log(`value={env}`)" >> "$GITHUB_OUTPUT" + env: + flavor: ${{ github.event.inputs.flavor }} + deploy: name: Deploy to cluster if: ${{ github.event_name == 'workflow_dispatch' || github.ref_type == 'tag' }} - environment: ${{ github.event.inputs.flavor }} + environment: ${{ needs.setup-deploy-environment.outputs.environment }} permissions: contents: 'write' id-token: 'write' needs: - build-docker + - setup-deploy-environment runs-on: ubuntu-latest steps: - uses: actions/checkout@v4