Skip to content

Commit

Permalink
add html processing scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
happylolonly committed Jul 31, 2024
1 parent 70817eb commit 3e21cbc
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 1 deletion.
21 changes: 21 additions & 0 deletions .github/workflows/modify_html/add_analytics.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/sh

analytics_script=$(cat <<'EOF'
<script>
const script = document.createElement('script');
script.src = 'https://metrics.cyb.ai/js/script.js';
script.setAttribute('data-domain', location.host);
script.defer = true;
document.body.appendChild(script);
</script>
EOF
)


find $GITHUB_WORKSPACE/build -name 'index.html' -exec sh -c '
for file do
sed "/<\/html>/i $analytics_script" "$file"
done
' sh {} +


17 changes: 17 additions & 0 deletions .github/workflows/modify_html/add_meta.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh

metas=$(cat <<'EOF'
<meta property="og:title" content="cyber docs">
<meta name="description" content="cyber docs">
<meta property="og:description" content="cyber docs">
<meta property="og:image" content="/static/img/logo.png">
EOF
)

find $GITHUB_WORKSPACE/build -name 'index.html' -exec sh -c '
for file do
sed "/<\/head>/i $metas" "$file"
done
' sh {} +
9 changes: 8 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
on:
push:
branches:
branches:
- master

permissions:
Expand All @@ -18,6 +18,13 @@ jobs:
output-directory: build
- name: Add a nojekyll file # to make sure asset paths are correctly identified
run: touch $GITHUB_WORKSPACE/build/.nojekyll
- name: Replace logo file
run: cp assets/logo.png $GITHUB_WORKSPACE/build/static/img/logo.png
- name: Add meta
run: ./modify_html/add_meta.sh
- name: Add analytics script
run: ./modify_html/add_analytics.sh

- name: Deploy to Netlify
uses: jsmrcaga/[email protected]
with:
Expand Down
Binary file added assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 3e21cbc

Please sign in to comment.