From 8c166d67bc61958c848dd6ea464076ddf1e6cb35 Mon Sep 17 00:00:00 2001 From: sarahschwartz <58856580+sarahschwartz@users.noreply.github.com> Date: Mon, 23 Oct 2023 09:54:40 -0600 Subject: [PATCH] refactor --- .github/workflows/guides.yml | 21 ------------------- .github/workflows/links.yml | 32 +++++++++++++++++++++++++++++ mlc-config.json | 2 +- scripts/generate-mlc-config.mjs | 12 +++++++++++ scripts/update-latest-submodules.sh | 3 --- 5 files changed, 45 insertions(+), 25 deletions(-) create mode 100644 .github/workflows/links.yml create mode 100644 scripts/generate-mlc-config.mjs delete mode 100644 scripts/update-latest-submodules.sh diff --git a/.github/workflows/guides.yml b/.github/workflows/guides.yml index 6d6ddb07f..d6411bb1d 100644 --- a/.github/workflows/guides.yml +++ b/.github/workflows/guides.yml @@ -21,27 +21,6 @@ jobs: - name: Lint Check run: markdownlint --config .markdownlint.yaml --ignore-path .markdownlintignore '**/*.mdx' - ## CHECKS ALL LINKS IN GUIDES - ## RUNS AFTER VERCEL LINK IS DEPLOYED - check-links: - name: Check Links - runs-on: ubuntu-latest - steps: - # SETUP & INSTALL - - name: Checkout repo - uses: actions/checkout@v3 - - uses: ./.github/actions/setup-node - with: - install: false - # RUN SCRIPT TO GENERATE NEW CONFIG WITH VERCEL PREVIEW URL - # RUN LINK CHECK - - uses: gaurav-nelson/github-action-markdown-link-check - with: - config-file: 'mlc-config.json' - file-extension: 'mdx' - use-verbose-mode: 'yes' - folder-path: docs/guides/docs - ## QUICKSTART TEST quickstart-test: timeout-minutes: 30 diff --git a/.github/workflows/links.yml b/.github/workflows/links.yml new file mode 100644 index 000000000..e1cf3ed59 --- /dev/null +++ b/.github/workflows/links.yml @@ -0,0 +1,32 @@ +name: Links + +on: + workflow_run: + workflows: [Vercel] + types: + - completed + +jobs: + ## CHECKS ALL LINKS IN GUIDES + ## RUNS AFTER VERCEL LINK IS DEPLOYED + check-links: + name: Check Links + runs-on: ubuntu-latest + steps: + # SETUP & INSTALL + - name: Checkout repo + 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 SCRIPT TO GENERATE NEW CONFIG WITH VERCEL PREVIEW URL + # RUN LINK CHECK + - uses: gaurav-nelson/github-action-markdown-link-check + with: + config-file: 'mlc-config.json' + file-extension: 'mdx' + # use-verbose-mode: 'yes' + folder-path: docs/guides/docs diff --git a/mlc-config.json b/mlc-config.json index 5ded0fc17..253f43afc 100644 --- a/mlc-config.json +++ b/mlc-config.json @@ -26,7 +26,7 @@ "replacementPatterns": [ { "pattern": "^(/)(.*)", - "replacement": "https://docs-hub-git-sarah-lint-fuel-labs.vercel.app/$2" + "replacement": "https://docs-hub-git-{{BRANCH}}-fuel-labs.vercel.app/$2" } ] } diff --git a/scripts/generate-mlc-config.mjs b/scripts/generate-mlc-config.mjs new file mode 100644 index 000000000..a9c585b63 --- /dev/null +++ b/scripts/generate-mlc-config.mjs @@ -0,0 +1,12 @@ +import fs from 'fs'; + +main(); + +function main() { + 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); + fs.writeFileSync(configPath, newContent); +} diff --git a/scripts/update-latest-submodules.sh b/scripts/update-latest-submodules.sh deleted file mode 100644 index 62428ab63..000000000 --- a/scripts/update-latest-submodules.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -git submodule update --remote docs/latest/sway docs/latest/builds/sway docs/latest/fuel-graphql-docs docs/latest/fuel-indexer docs/latest/fuel-specs docs/latest/fuels-rs docs/latest/fuels-ts docs/latest/fuels-wallet docs/latest/fuelup \ No newline at end of file