Deploy Explorer #10
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: Deploy Explorer | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| deploy_type: | |
| description: "Deploy type" | |
| required: true | |
| type: choice | |
| options: | |
| - staging | |
| - rc | |
| - production | |
| jobs: | |
| resolve-deploy-type: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| deploy_type: ${{ steps.resolve.outputs.deploy_type }} | |
| environment: ${{ steps.resolve.outputs.environment }} | |
| apps_backend_secret: ${{ steps.resolve.outputs.apps_backend_secret }} | |
| steps: | |
| - name: Resolve deploy type | |
| id: resolve | |
| run: | | |
| DEPLOY_TYPE="${{ inputs.deploy_type }}" | |
| case "$DEPLOY_TYPE" in | |
| staging) | |
| ENVIRONMENT="Staging – explorer" | |
| APPS_BACKEND_SECRET="STAGING_APPS_BACKEND" | |
| ;; | |
| rc) | |
| ENVIRONMENT="RC – explorer" | |
| APPS_BACKEND_SECRET="RC_APPS_BACKEND" | |
| ;; | |
| production) | |
| ENVIRONMENT="Production – explorer" | |
| APPS_BACKEND_SECRET="PROD_APPS_BACKEND" | |
| ;; | |
| esac | |
| echo "deploy_type=$DEPLOY_TYPE" >> "$GITHUB_OUTPUT" | |
| echo "environment=$ENVIRONMENT" >> "$GITHUB_OUTPUT" | |
| echo "apps_backend_secret=$APPS_BACKEND_SECRET" >> "$GITHUB_OUTPUT" | |
| deploy: | |
| needs: resolve-deploy-type | |
| runs-on: ubuntu-latest | |
| environment: ${{ needs.resolve-deploy-type.outputs.environment }} | |
| permissions: | |
| contents: read | |
| env: | |
| VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} | |
| VERCEL_PROJECT_ID: ${{ secrets.EXPLORER_VERCEL_PROJECT_ID }} | |
| SENTRY_AUTH_TOKEN: ${{ secrets.TOOLING_SENTRY_AUTH_TOKEN }} | |
| APPS_BACKEND: ${{ secrets[needs.resolve-deploy-type.outputs.apps_backend_secret] }} | |
| steps: | |
| - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 | |
| - uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0 | |
| - name: Install Nodejs | |
| uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 | |
| with: | |
| node-version: "24" | |
| cache: "pnpm" | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Install Vercel CLI | |
| run: pnpm add --global vercel@canary | |
| - name: Pull Vercel Env variables and deploy | |
| id: deploy | |
| run: | | |
| DEPLOY_TYPE="${{ needs.resolve-deploy-type.outputs.deploy_type }}" | |
| VERCEL_FLAGS="--token=${{ secrets.VERCEL_TOKEN }} --scope=${{ secrets.VERCEL_SCOPE }}" | |
| case "$DEPLOY_TYPE" in | |
| production) VERCEL_ENV="production" ;; | |
| staging) VERCEL_ENV="staging" ;; | |
| rc) VERCEL_ENV="preview" ;; | |
| esac | |
| echo "Deploy type: ${DEPLOY_TYPE}, Vercel environment: ${VERCEL_ENV}" | |
| vercel pull --yes --environment="$VERCEL_ENV" $VERCEL_FLAGS | |
| cp "./.vercel/.env.${VERCEL_ENV}.local" ./sdk/.env | |
| if [ "$DEPLOY_TYPE" = "production" ]; then | |
| vercel build --prod $VERCEL_FLAGS | |
| vercel deploy --prod --prebuilt $VERCEL_FLAGS | |
| echo "url=https://explorer.iota.org" >> "$GITHUB_OUTPUT" | |
| elif [ "$DEPLOY_TYPE" = "rc" ]; then | |
| vercel build $VERCEL_FLAGS | |
| DEPLOY_URL=$(vercel deploy --prebuilt $VERCEL_FLAGS) | |
| vercel alias set "$DEPLOY_URL" explorer-rc-iota1.vercel.app $VERCEL_FLAGS | |
| echo "url=https://explorer-rc-iota1.vercel.app" >> "$GITHUB_OUTPUT" | |
| else | |
| vercel build $VERCEL_FLAGS | |
| echo "url=$(vercel deploy --prebuilt $VERCEL_FLAGS)" >> "$GITHUB_OUTPUT" | |
| fi | |
| notify: | |
| needs: [resolve-deploy-type, deploy] | |
| if: always() && needs.deploy.result != 'skipped' && (needs.resolve-deploy-type.outputs.deploy_type == 'rc' || needs.resolve-deploy-type.outputs.deploy_type == 'production') | |
| uses: ./.github/workflows/_slack_notify.yml | |
| secrets: inherit | |
| with: | |
| status: ${{ needs.deploy.result == 'success' && 'success' || 'failure' }} | |
| title: "Explorer ${{ needs.resolve-deploy-type.outputs.deploy_type }} deploy ${{ needs.deploy.result }}" | |
| message: | | |
| Environment: ${{ needs.resolve-deploy-type.outputs.deploy_type }} | |
| URL: ${{ needs.resolve-deploy-type.outputs.deploy_type == 'production' && 'https://explorer.iota.org' || 'https://explorer-rc-iota1.vercel.app' }} | |
| Workflow Run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | |