Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahschwartz committed Oct 23, 2023
1 parent 82acdbd commit f8de6d3
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 18 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/links.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ jobs:
# RUN SCRIPT TO USE VERCEL PREVIEW LINK FROM PR
- name: Update preview link
run: node scripts/generate-mlc-config.mjs ${{ github.event.deployment_status.state }} ${{ 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
# with:
# config-file: 'mlc-config.json'
# file-extension: 'mdx'
# # use-verbose-mode: 'yes'
# folder-path: docs/guides/docs
# 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
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": "{{VERCEL_PREVIEW}}$2"
"replacement": "{{VERCEL_PREVIEW}}/$2"
}
]
}
24 changes: 15 additions & 9 deletions scripts/generate-mlc-config.mjs
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
// import fs from 'fs';
import fs from 'fs';

main();

const configPath = './mlc-config-test.json';

function main() {
console.log('DEPLOYMENT STATE:', process.argv[2]);
console.log('DEPLOYMENT URL:', process.argv[3]);
// const previewURL = process.argv[2];
// console.log('PREVIEW URL:', previewURL);
// const configPath = './mlc-config-test.json';
// const configFile = fs.readFileSync(configPath, 'utf-8');
// const newContent = configFile.replace('{{VERCEL_PREVIEW}}', previewURL);
// fs.writeFileSync(configPath, newContent);
const deploymentState = process.argv[2];
console.log('DEPLOYMENT STATE:', deploymentState);
const deploymentURL = process.argv[3];
console.log('DEPLOYMENT URL:', deploymentURL);

if (deploymentState === 'success' && deploymentURL) {
const configFile = fs.readFileSync(configPath, 'utf-8');
const newContent = configFile.replace('{{VERCEL_PREVIEW}}', deploymentURL);
fs.writeFileSync(configPath, newContent);
} else {
throw Error('MISSING VERCEL DEPLOYMENT');
}
}

0 comments on commit f8de6d3

Please sign in to comment.