From 2541d3e756c83788125ab4c605ea9fe44f83ef12 Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 21 Jan 2025 20:18:35 +0000 Subject: [PATCH] Run the action only on dispatch --- .github/workflows/ci-website.yml | 24 ----------------- .github/workflows/create-vercel-alias.yml | 32 +++++++++++++++++++++++ 2 files changed, 32 insertions(+), 24 deletions(-) create mode 100644 .github/workflows/create-vercel-alias.yml diff --git a/.github/workflows/ci-website.yml b/.github/workflows/ci-website.yml index d9df58f37bd..e2a40713f62 100644 --- a/.github/workflows/ci-website.yml +++ b/.github/workflows/ci-website.yml @@ -69,27 +69,3 @@ jobs: - name: Run Tests run: yarn run test:ember working-directory: website - - create-vercel-alias: - name: 'Create Vercel Alias' - runs-on: ubuntu-latest - needs: [test] - steps: - - uses: actions/checkout@v2 - - name: Extract Current Version - id: extract_version - run: echo "VERSION=$(jq -r .version packages/components/package.json | sed 's/\./-/g')" >> $GITHUB_ENV - - name: Get Latest Vercel Deployment - id: get_vercel_deployment - run: | - DEPLOYMENT_ID=$(curl -s -H "Authorization: Bearer ${{ secrets.VERCEL_TOKEN }}" \ - "https://api.vercel.com/v6/deployments?teamId=${{ secrets.VERCEL_TEAM_ID }}&projectId=${{ secrets.VERCEL_WEBSITE_PROJECT_ID }}" \ - | jq -r --arg branch "${{ github.head_ref }}" '.deployments[] | select(.meta.githubCommitRef == $branch) | .uid' | head -n 1) - echo "DEPLOYMENT_ID=$DEPLOYMENT_ID" >> $GITHUB_ENV - - name: Alias Vercel Deployment - id: alias_vercel_deployment - run: | - curl -X POST "https://api.vercel.com/v2/deployments/${{ env.DEPLOYMENT_ID }}/aliases?slug=hashicorp&teamId=${{ secrets.VERCEL_TEAM_ID }}" \ - -H "Authorization: Bearer ${{ secrets.VERCEL_TOKEN }}" \ - -H "Content-Type: application/json" \ - -d "{\"alias\": \"hds-website-${{ env.VERSION }}-test.vercel.app\", \"teamId\": \"${{ secrets.VERCEL_TEAM_ID }}\", \"slug\": \"hashicorp\"}" diff --git a/.github/workflows/create-vercel-alias.yml b/.github/workflows/create-vercel-alias.yml new file mode 100644 index 00000000000..65baa175050 --- /dev/null +++ b/.github/workflows/create-vercel-alias.yml @@ -0,0 +1,32 @@ + +name: 'Create Vercel Alias' + +on: + workflow_dispatch: + +env: + NODE_VERSION: '22.x' + +jobs: + create-vercel-alias: + name: 'Create Vercel Alias' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Extract Current Version + id: extract_version + run: echo "VERSION=$(jq -r .version packages/components/package.json | sed 's/\./-/g')" >> $GITHUB_ENV + - name: Get Latest Vercel Deployment + id: get_vercel_deployment + run: | + DEPLOYMENT_ID=$(curl -s -H "Authorization: Bearer ${{ secrets.VERCEL_TOKEN }}" \ + "https://api.vercel.com/v6/deployments?teamId=${{ secrets.VERCEL_TEAM_ID }}&projectId=${{ secrets.VERCEL_WEBSITE_PROJECT_ID }}" \ + | jq -r --arg branch "${{ github.head_ref }}" '.deployments[] | select(.meta.githubCommitRef == $branch) | .uid' | head -n 1) + echo "DEPLOYMENT_ID=$DEPLOYMENT_ID" >> $GITHUB_ENV + - name: Alias Vercel Deployment + id: alias_vercel_deployment + run: | + curl -X POST "https://api.vercel.com/v2/deployments/${{ env.DEPLOYMENT_ID }}/aliases?slug=hashicorp&teamId=${{ secrets.VERCEL_TEAM_ID }}" \ + -H "Authorization: Bearer ${{ secrets.VERCEL_TOKEN }}" \ + -H "Content-Type: application/json" \ + -d "{\"alias\": \"hds-website-${{ env.VERSION }}.vercel.app\", \"teamId\": \"${{ secrets.VERCEL_TEAM_ID }}\", \"slug\": \"hashicorp\"}"