From 93d922afc25eecba011811cd4ceebbc56851d2a0 Mon Sep 17 00:00:00 2001 From: sarahschwartz <58856580+sarahschwartz@users.noreply.github.com> Date: Mon, 23 Oct 2023 10:48:01 -0600 Subject: [PATCH] fix --- .github/workflows/links.yml | 14 ++++---------- mlc-config.json | 2 +- scripts/generate-mlc-config.mjs | 6 +++--- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/.github/workflows/links.yml b/.github/workflows/links.yml index 0688db350..f8c2457af 100644 --- a/.github/workflows/links.yml +++ b/.github/workflows/links.yml @@ -1,25 +1,19 @@ name: Links on: - deployment_status: - + deployment_status: jobs: - ## CHECKS ALL LINKS IN GUIDES - ## RUNS AFTER VERCEL LINK IS DEPLOYED - check-links: + run-e2es: if: github.event_name == 'deployment_status' && github.event.deployment_status.state == 'success' - name: Check Links runs-on: ubuntu-latest steps: - # SETUP & INSTALL - - name: Checkout repo - uses: actions/checkout@v3 + - uses: actions/checkout@v3 - uses: ./.github/actions/setup-node with: install: false # RUN SCRIPT TO USE VERCEL PREVIEW LINK FROM PR - name: Update preview link - run: node scripts/generate-mlc-config.mjs {{ github.head_ref }} + run: node scripts/generate-mlc-config.mjs ${{ github.event.deployment_status.environment_url }} # RUN SCRIPT TO GENERATE NEW CONFIG WITH VERCEL PREVIEW URL # RUN LINK CHECK - uses: gaurav-nelson/github-action-markdown-link-check diff --git a/mlc-config.json b/mlc-config.json index 253f43afc..79e50f695 100644 --- a/mlc-config.json +++ b/mlc-config.json @@ -26,7 +26,7 @@ "replacementPatterns": [ { "pattern": "^(/)(.*)", - "replacement": "https://docs-hub-git-{{BRANCH}}-fuel-labs.vercel.app/$2" + "replacement": "{{VERCEL_PREVIEW}}$2" } ] } diff --git a/scripts/generate-mlc-config.mjs b/scripts/generate-mlc-config.mjs index a9c585b63..e40e2e688 100644 --- a/scripts/generate-mlc-config.mjs +++ b/scripts/generate-mlc-config.mjs @@ -3,10 +3,10 @@ import fs from 'fs'; main(); function main() { + const previewURL = process.argv[2]; + console.log('PREVIEW URL:', previewURL); const configPath = './mlc-config-test.json'; - const branchName = process.argv[2].replaceAll('/', '-').toLowerCase(); - console.log('BRANCH NAME:', branchName); const configFile = fs.readFileSync(configPath, 'utf-8'); - const newContent = configFile.replace('{{BRANCH}}', branchName); + const newContent = configFile.replace('{{VERCEL_PREVIEW}}', previewURL); fs.writeFileSync(configPath, newContent); }