Skip to content

Commit

Permalink
feat: implement build preview with latest styles (wip)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulovareiro29 committed Aug 9, 2024
1 parent 446e05e commit 0d2d368
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 10 deletions.
17 changes: 7 additions & 10 deletions .github/workflows/deploy-to-github-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,13 @@ jobs:
- name: Generate index file
run: |
echo "<html>
<head>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
</head>
<body><h1>Deployed Branches</h1><ul>" > deployment/index.html
for archive in deployment/archives/*.tar; do
branch_name=$(basename $archive .tar)
echo "<li><a href='./${branch_name}/'>${branch_name}</a></li>" >> deployment/index.html
done
echo "</ul></body></html>" >> deployment/index.html
branches=$(ls deployment/archives/*.tar | xargs -n 1 basename | sed 's/.tar//')
echo "branches=$branches" >> $GITHUB_ENV
node scripts/build-preview.js $branches > deployment/index.html
cp deployment/index.html src/pages/preview.twig
pnpm build
rm deployment/index.html
mv dist/preview.html deployment/index.html
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
Expand Down
26 changes: 26 additions & 0 deletions scripts/build-preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const processBranches = (branches) =>
branches
.map((branch) => `<li><a href='./${branch}/'>${branch}</a></li>`)
.join('')

const main = () => {
const branches = process.argv.slice(2)
console.log(
`
<html>
<head>
<title>Stadt Koeln - Open Data</title>
<link rel='stylesheet' href='/src/styles/styles.scss'>
</head>
<body>
<h1>Deployed Branches</h1>
<ul>
${processBranches(branches)}
</ul>
</body>
</html>
`.trim()
)
}

main()

0 comments on commit 0d2d368

Please sign in to comment.