-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/debugging copy files adding logging (#4)
* Adding logging, disabled copy * Modified to run on push to all branches for debugging * Fixing pipeline file bug * Fixing an error due to shell types in convert script * Reverting changes to path loop * Script path for printing file contents was wrong * Updating script permissions * Updated pipelines for main and other branches
- Loading branch information
1 parent
29f559e
commit a6395b7
Showing
12 changed files
with
145 additions
and
30 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
22 changes: 11 additions & 11 deletions
22
.github/scripts/addFrontMatter.sh → .github/scripts/debug/addFrontMatter.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
#!/bin/sh | ||
#!/bin/bash | ||
|
||
basePath="./KnowledgeBase/" | ||
startEnd="---" | ||
#tab=" " | ||
|
||
echo "[DEBUG] Adding front matter to all markdown files in ${basePath}..." | ||
|
||
find ${basePath} -type f \( -iname "*.md" ! -iname "*index*" ! -iname "*readme*" \) -print | while IFS= read -r path; do | ||
echo "[DEBUG] Adding front matter to ${path}..." | ||
subject=$(dirname "${path}") # generate a category from the parent directory of the file | ||
subjectLower=$(dirname "${path}" | awk -F "/" '{print tolower($NF)}') # generate a category from the parent directory of the file - in lowercase | ||
title=$(basename -s .md "${path}") # generate a title from the file name | ||
titleLower=$(echo "${title}" | awk '{print tolower($0)}') # set the title to lowercase | ||
titleSpaces=$(echo "${title}" | tr "-" " " ) # replace hyphens with spaces | ||
excerpt=$(sed -n 3p "${path}") # get the first non-title line of the file | ||
# Remove special chracters from excerpt | ||
excerpt=$(echo "${excerpt}" | sed -e 's/[^a-zA-Z0-9 ]//g') | ||
excerpt=$(echo "${excerpt}" | sed -e 's/[^a-zA-Z0-9 ]//g') # Remove special chracters from excerpt | ||
frontMatter="${startEnd}\npermalink: /knowledge/${titleLower}/\nsubject: ${subject}\ntitle: ${titleSpaces}\nexcerpt: "${excerpt}"\n${startEnd}" # build Liquid Front Matter - builds multiline string | ||
# Removed the subject from the front matter as the path on my website does not include the subject and all posts as from /knowledge | ||
#frontMatter="${startEnd}\npermalink: /knowledge/${subjectLower}/${titleLower}/\nsubject: ${subject}\ntitle: ${titleSpaces}\nexcerpt: "${excerpt}"\n${startEnd}" # build Liquid Front Matter - builds multiline string | ||
echo "[DEBUG] Front matter: ${frontMatter}" | ||
sed -i "1i ${frontMatter}" "${path}" # prepend the front matter to the head of the file | ||
# Add new line after end of file | ||
echo "" >> "${path}" | ||
# Append breadcrumbs include to the end of the file on a new line and adding a new line to the end of the file | ||
echo "{% include breadcrumbs2.html %}" >> "${path}" | ||
echo "" >> "${path}" # Add new line after end of file | ||
echo "{% include breadcrumbs2.html %}" >> "${path}" # Append breadcrumbs include to the end of the file on a new line and adding a new line to the end of the file | ||
echo "[DEBUG] Front matter added to ${path}." | ||
done | ||
|
||
echo "[DEBUG] Front matter added to all markdown files in ${basePath}." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
|
||
basePath="./KnowledgeBase/" | ||
|
||
echo "[DEBUG] Converting all H1 to H2 in all markdown files in ${basePath}..." | ||
|
||
for path in $(find ${basePath} -type f \( -iname "*.md" ! -iname "*index*" ! -iname "*readme*" \) -print); do | ||
echo "[DEBUG] Converting all H1 to H2 in ${path}..." | ||
# Replace all instances of # with ## - this converts all H1 to H2 | ||
sed -i 's/\(^#\)\(\s\)/\#\#\2/g' "${path}" | ||
echo "[DEBUG] All H1 converted to H2 in ${path}." | ||
done | ||
|
||
echo "[DEBUG] All H1 converted to H2 in all markdown files in ${basePath}." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
|
||
# Directory containing the markdown files | ||
dir="./KnowledgeBase/" | ||
|
||
echo "[DEBUG] Generating output for all markdown files in $dir" | ||
|
||
# Find all markdown files in the directory and its subdirectories | ||
find $dir -name "*.md" | while read -r file; do | ||
echo "[DEBUG] Found markdown file: $file" | ||
echo "Printing contents of $file" | ||
cat "$file" | ||
done | ||
|
||
echo "[DEBUG] Done generating output for all markdown files in $dir" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
basePath="./KnowledgeBase/" | ||
|
||
echo "[DEBUG] Converting all links to lowercase permalinks in all markdown files in ${basePath}..." | ||
|
||
find ${basePath} -type f \( -iname "*.md" ! -iname "*index*" ! -iname "*readme*" \) -print | while IFS= read -r path; do | ||
echo "[DEBUG] Converting all links to lowercase permalinks in ${path}..." | ||
sed -i`` 's/\(.*\).md/\L\1/g' "${path}" # convert links to other markdown files to lowercase permalinks with .md extension removed | ||
echo "[DEBUG] All links converted to lowercase permalinks in ${path}." | ||
done | ||
|
||
echo "[DEBUG] All links converted to lowercase permalinks in all markdown files in ${basePath}." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
|
||
basePath="./KnowledgeBase/" | ||
startEnd="---" | ||
|
||
echo "[INFO] Adding front matter to all markdown files in ${basePath}..." | ||
|
||
find ${basePath} -type f \( -iname "*.md" ! -iname "*index*" ! -iname "*readme*" \) -print | while IFS= read -r path; do | ||
echo "[INFO] Adding front matter to ${path}..." | ||
subject=$(dirname "${path}") # generate a category from the parent directory of the file | ||
title=$(basename -s .md "${path}") # generate a title from the file name | ||
titleLower=$(echo "${title}" | awk '{print tolower($0)}') # set the title to lowercase | ||
titleSpaces=$(echo "${title}" | tr "-" " " ) # replace hyphens with spaces | ||
excerpt=$(sed -n 3p "${path}") # get the first non-title line of the file | ||
excerpt=$(echo "${excerpt}" | sed -e 's/[^a-zA-Z0-9 ]//g') # Remove special chracters from excerpt | ||
frontMatter="${startEnd}\npermalink: /knowledge/${titleLower}/\nsubject: ${subject}\ntitle: ${titleSpaces}\nexcerpt: "${excerpt}"\n${startEnd}" # build Liquid Front Matter - builds multiline string | ||
sed -i "1i ${frontMatter}" "${path}" # prepend the front matter to the head of the file | ||
echo "" >> "${path}" # Add new line after end of file | ||
echo "{% include breadcrumbs2.html %}" >> "${path}" # Append breadcrumbs include to the end of the file on a new line and adding a new line to the end of the file | ||
echo "[INFO] Front matter added to ${path}." | ||
done | ||
|
||
echo "[INFO] Front matter added to all markdown files in ${basePath}." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
basePath="./KnowledgeBase/" | ||
|
||
echo "[INFO] Converting all H1 to H2 in all markdown files in ${basePath}..." | ||
|
||
for path in $(find ${basePath} -type f \( -iname "*.md" ! -iname "*index*" ! -iname "*readme*" \) -print); do | ||
echo "[INFO] Converting all H1 to H2 in ${path}..." | ||
sed -i 's/\(^#\)\(\s\)/\#\#\2/g' "${path}" # Replace all instances of # with ## - this converts all H1 to H2 | ||
echo "[INFO] All H1 converted to H2 in ${path}." | ||
done | ||
|
||
echo "[INFO] All H1 converted to H2 in all markdown files in ${basePath}." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
|
||
# Directory containing the markdown files | ||
dir="./KnowledgeBase/" | ||
|
||
echo "[INFO] Generating output for all markdown files in $dir" | ||
|
||
# Find all markdown files in the directory and its subdirectories | ||
find $dir -name "*.md" | while read -r file; do | ||
echo "[INFO] Found markdown file: $file" | ||
echo "Printing contents of $file" | ||
cat "$file" | ||
done | ||
|
||
echo "[INFO] Done generating output for all markdown files in $dir" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
basePath="./KnowledgeBase/" | ||
|
||
echo "[INFO] Converting all links to lowercase permalinks in all markdown files in ${basePath}..." | ||
|
||
find ${basePath} -type f \( -iname "*.md" ! -iname "*index*" ! -iname "*readme*" \) -print | while IFS= read -r path; do | ||
echo "[INFO] Converting all links to lowercase permalinks in ${path}..." | ||
sed -i`` 's/\(.*\).md/\L\1/g' ${path} # convert links to other markdown files to lowercase permalinks with .md extension removed | ||
echo "[INFO] All links converted to lowercase permalinks in ${path}." | ||
done | ||
|
||
echo "[INFO] All links converted to lowercase permalinks in all markdown files in ${basePath}." |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,11 +19,11 @@ jobs: | |
with: | ||
submodules: true | ||
- name: Add Front Matter | ||
run: .github/scripts/addFrontMatter.sh | ||
run: .github/scripts/prod/addFrontMatter.sh | ||
- name: Update Links | ||
run: .github/scripts/updateLinks.sh | ||
run: .github/scripts/prod/updateLinks.sh | ||
- name: Convert H1 to H2 | ||
run: .github/scripts/convertH1toH2.sh | ||
run: .github/scripts/prod/convertH1toH2.sh | ||
- name: Copy files to GrahamWattsWeb | ||
uses: nkoppel/[email protected] | ||
env: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Verify Output | ||
|
||
on: | ||
push: | ||
branches: | ||
- '*' | ||
- '!main' | ||
workflow_dispatch: | ||
|
||
jobs: | ||
copy-to-grahamwattsweb: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: checkout KnowledgeBase | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: true | ||
- name: Add Front Matter | ||
run: .github/scripts/debug/addFrontMatter.sh | ||
- name: Update Links | ||
run: .github/scripts/debug/updateLinks.sh | ||
- name: Convert H1 to H2 | ||
run: .github/scripts/debug/convertH1toH2.sh | ||
- name: "[DEBUG] Show file contents" | ||
run: .github/scripts/debug/printFileContents.sh |