feat: add api/env #51
Workflow file for this run
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: Prerelease | |
| on: | |
| workflow_dispatch: | |
| pull_request: | |
| types: | |
| - opened | |
| - labeled | |
| - synchronize | |
| permissions: | |
| pull-requests: write | |
| issues: write | |
| contents: write | |
| deployments: write | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| include: | |
| - locale: en | |
| secret_project_id: VERCEL_PROJECT_EN_ID | |
| - locale: zh-hans | |
| secret_project_id: VERCEL_PROJECT_ZH_HANS_ID | |
| - locale: zh-hant | |
| secret_project_id: VERCEL_PROJECT_ZH_HANT_ID | |
| name: Deploy ${{ matrix.locale }} | |
| steps: | |
| # Calculate if this matrix job should run based on PR labels | |
| # | |
| # This job will deploy if: | |
| # - The event is NOT a pull_request (e.g., workflow_dispatch) | |
| # - OR the PR has the label 'prerelease' | |
| # - OR the PR has the label 'prerelease:<locale>' matching the current matrix locale | |
| - name: Calculate should_deploy | |
| id: should_deploy | |
| shell: bash | |
| run: | | |
| LABELS_JSON='${{ toJson(github.event.pull_request.labels.*.name) }}' | |
| echo "LABELS_JSON: $LABELS_JSON" | |
| SHOULD_DEPLOY=false | |
| if [[ "${{ github.event_name }}" != "pull_request" ]]; then | |
| SHOULD_DEPLOY=true | |
| elif echo "$LABELS_JSON" | grep -E '"prerelease"' > /dev/null; then | |
| SHOULD_DEPLOY=true | |
| elif echo "$LABELS_JSON" | grep -E '"prerelease:'"${{ matrix.locale }}"'"' > /dev/null; then | |
| SHOULD_DEPLOY=true | |
| fi | |
| echo "should_deploy=$SHOULD_DEPLOY" >> $GITHUB_OUTPUT | |
| - name: Checkout code | |
| if: steps.should_deploy.outputs.should_deploy == 'true' | |
| uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 1 | |
| ref: ${{ github.head_ref }} | |
| - name: Log checked out commit | |
| if: steps.should_deploy.outputs.should_deploy == 'true' | |
| run: git log -1 | |
| - name: Setup Tools | |
| if: steps.should_deploy.outputs.should_deploy == 'true' | |
| uses: ./.github/actions/setup | |
| - name: Install Vercel CLI | |
| run: npm install -g vercel@22.0.1 | |
| - name: Deploy to Vercel Action | |
| if: steps.should_deploy.outputs.should_deploy == 'true' | |
| uses: BetaHuhn/deploy-to-vercel-action@v1.10.0 | |
| with: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} | |
| VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} | |
| VERCEL_PROJECT_ID: ${{ secrets[matrix.secret_project_id] }} | |
| GITHUB_DEPLOYMENT: false | |
| # PR_PREVIEW_DOMAIN: "${{ matrix.locale }}.{PR}.nextjs.im" | |
| # - name: Deploy to Vercel (${{ matrix.locale }}) | |
| # if: steps.should_deploy.outputs.should_deploy == 'true' | |
| # id: deploy | |
| # uses: ./.github/actions/vercel-deploy | |
| # with: | |
| # environment: preview | |
| # vercel_project_id: ${{ secrets[matrix.secret_project_id] }} | |
| # vercel_org_id: ${{ secrets.VERCEL_ORG_ID }} | |
| # vercel_token: ${{ secrets.VERCEL_TOKEN }} | |
| # - name: Comment PR with Vercel Preview Links (${{ matrix.locale }}) | |
| # if: steps.should_deploy.outputs.should_deploy == 'true' | |
| # uses: ./.github/actions/comment-vercel-preview | |
| # with: | |
| # inspect_url: ${{ steps.deploy.outputs.inspect_url }} | |
| # preview_url: ${{ steps.deploy.outputs.prod_url }} | |
| # label: ${{ matrix.locale }} |