Skip to content

Register Preview URL with CloudIDP #14519

Register Preview URL with CloudIDP

Register Preview URL with CloudIDP #14519

# This workflow enables HashiCorp Oauth on Vercel preview deployments.
name: Register Preview URL with CloudIDP
on:
deployment_status:
# workflow_dispatch is here for supporting manual iteration
workflow_dispatch:
inputs:
preview_url:
description: 'A Vercel preview url. Only used during manual runs'
required: true
jobs:
on-deploy:
runs-on: ubuntu-latest
if: github.event.deployment_status.state == 'success' && github.event.deployment_status.environment == 'Preview' && github.event.repository.name == 'dev-portal' || github.event_name == 'workflow_dispatch'
steps:
- name: summary
run: |
echo "# Summary" >> $GITHUB_STEP_SUMMARY
echo "Deployed to: ${{ github.event.deployment_status.environment }}" >> $GITHUB_STEP_SUMMARY
echo "Deployed State: ${{ github.event.deployment_status.state }}" >> $GITHUB_STEP_SUMMARY
echo "target_url: ${{ github.event.deployment_status.target_url }}" >> $GITHUB_STEP_SUMMARY
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
with:
node-version-file: 'package.json'
- name: Install dependencies
run: npm ci
- name: Add Preview URL to CloudIDP
run: npx hc-tools ./scripts/add-preview-url-to-cloud-idp.ts
env:
# parameters
PREVIEW_URL: ${{ inputs.preview_url || github.event.deployment_status.target_url }}
# secrets
CLOUD_IDP_DEPLOYMENT_PREVIEW_PRIVATE_KEY: ${{ secrets.CLOUD_IDP_DEPLOYMENT_PREVIEW_PRIVATE_KEY }}
FLOW_IDP_DEPLOYMENT_READY_URL: ${{ secrets.FLOW_IDP_DEPLOYMENT_READY_URL }}
VERCEL_API_TOKEN: ${{ secrets.VERCEL_API_TOKEN }}
VERCEL_TEAM_ID: ${{ secrets.VERCEL_TEAM_ID }}