Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahschwartz committed Oct 23, 2023
1 parent 5a5f8f5 commit 93d922a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
14 changes: 4 additions & 10 deletions .github/workflows/links.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion mlc-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"replacementPatterns": [
{
"pattern": "^(/)(.*)",
"replacement": "https://docs-hub-git-{{BRANCH}}-fuel-labs.vercel.app/$2"
"replacement": "{{VERCEL_PREVIEW}}$2"
}
]
}
6 changes: 3 additions & 3 deletions scripts/generate-mlc-config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

0 comments on commit 93d922a

Please sign in to comment.