From 61dfe72b4b066c69eed55d0a7f36d0cfdafedd4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20=C4=8Cerm=C3=A1k?= Date: Fri, 22 Nov 2024 10:37:24 +0100 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Refactor=20GitHub=20Action?= =?UTF-8?q?s=20workflows=20to=20use=20secrets=20for=20Vercel=20token=20man?= =?UTF-8?q?agement?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/preview-common.yaml | 13 +++++++------ .github/workflows/preview.yaml | 24 ++++++++++++++++++------ 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/.github/workflows/preview-common.yaml b/.github/workflows/preview-common.yaml index 69f44fe..7f9dfc1 100644 --- a/.github/workflows/preview-common.yaml +++ b/.github/workflows/preview-common.yaml @@ -9,9 +9,10 @@ on: vercel_scope: required: true type: string - vercel_token: + + secrets: + VERCEL_TOKEN: required: true - type: string jobs: shared-steps: @@ -29,13 +30,13 @@ jobs: run: corepack install - name: Link Project to Vercel - run: yarn dlx -q vercel link --project=${{ inputs.vercel_project_name }} --scope=${{ inputs.vercel_scope }} --yes --token=${{ inputs.vercel_token }} + run: yarn dlx -q vercel link --project=${{ inputs.vercel_project_name }} --scope=${{ inputs.vercel_scope }} --yes --token=${{ secrets.VERCEL_TOKEN }} - name: Pull Vercel Environment Information - run: yarn dlx -q vercel pull --yes --environment=preview --token=${{ inputs.vercel_token }} + run: yarn dlx -q vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }} - name: Build Project Artifacts - run: yarn dlx -q vercel build --token=${{ inputs.vercel_token }} + run: yarn dlx -q vercel build --token=${{ secrets.VERCEL_TOKEN }} - name: Deploy Project Artifacts to Vercel - run: yarn dlx -q vercel deploy --prebuilt --token=${{ inputs.vercel_token }} + run: yarn dlx -q vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }} diff --git a/.github/workflows/preview.yaml b/.github/workflows/preview.yaml index 2ddc3c4..26ff543 100644 --- a/.github/workflows/preview.yaml +++ b/.github/workflows/preview.yaml @@ -5,17 +5,29 @@ on: branches: - dev + workflow_call: + inputs: + VERCEL_PROJECT_DEFAULT: + required: true + type: string + VERCEL_PROJECT_UPGRADE: + required: true + type: string + VERCEL_SCOPE: + required: true + type: string + jobs: default-example: uses: ./.github/workflows/preview-common.yaml + secrets: inherit with: - vercel_project_name: ${{ secrets.VERCEL_NAME_EXAMPLE_DEFAULT }} - vercel_scope: ${{ secrets.VERCEL_SCOPE }} - vercel_token: ${{ secrets.VERCEL_TOKEN }} + vercel_project_name: ${{ inputs.VERCEL_PROJECT_DEFAULT }} + vercel_scope: ${{ inputs.VERCEL_SCOPE }} upgrade-example: uses: ./.github/workflows/preview-common.yaml + secrets: inherit with: - vercel_token: ${{ secrets.VERCEL_TOKEN }} - vercel_project_name: ${{ secrets.VERCEL_NAME_EXAMPLE_UPGRADE }} - vercel_scope: ${{ secrets.VERCEL_SCOPE }} + vercel_project_name: ${{ inputs.VERCEL_PROJECT_UPGRADE }} + vercel_scope: ${{ inputs.VERCEL_SCOPE }}