Update posts.json #175
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
name: Page Builder by ALMO | |
on: | |
push: | |
branches: | |
- main | |
permissions: | |
contents: write | |
pages: write | |
id-token: write | |
concurrency: build | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Check for Changes in MD Files | |
id: check_changes | |
run: | | |
changed_files=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep '\.md$' || true) | |
changed_files="${changed_files//'%'/'%25'}" | |
changed_files="${changed_files//$'\n'/'%0A'}" | |
changed_files="${changed_files//$'\r'/'%0D'}" | |
echo "changed_files=$changed_files" >> $GITHUB_OUTPUT | |
if [[ -z "$changed_files" ]]; then | |
echo "No changes in MD files. Skipping build." | |
else | |
echo "Change: $changed_files" | |
fi | |
- name: Setup Git | |
if: steps.check_changes.outputs.changed_files != '' | |
run: | | |
cd ${{ github.workspace }} | |
git config --global user.email "[email protected]" | |
git config --global user.name "GitHub Actions" | |
- name: Setup ALMO | |
if: steps.check_changes.outputs.changed_files != '' | |
run: | | |
git submodule update --init --recursive --remote | |
- name: Install g++ | |
if: steps.check_changes.outputs.changed_files != '' | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y g++ | |
- name: Compile almo.cpp | |
if: steps.check_changes.outputs.changed_files != '' | |
run: | | |
cd ALMO | |
bash build.sh | |
- name: Generate HTML Files | |
if: steps.check_changes.outputs.changed_files != '' | |
run: | | |
cd ${{ github.workspace }} | |
changed_files=${{ steps.check_changes.outputs.changed_files }} | |
changed_files="${changed_files//'%25'/'%'}" | |
changed_files="${changed_files//'%0A'/$'\n'}" | |
changed_files="${changed_files//'%0D'/$'\r'}" | |
echo "changed_files=$changed_files" | |
for file in $changed_files; do | |
if [ ! -e $file ]; then | |
continue | |
fi | |
filename_without_extension=$(basename $file .md) | |
filename_without_extension=${filename_without_extension#posts-md/} | |
out_path="public/posts/${filename_without_extension}.html" | |
echo "Generating HTML for $file" | |
python3 blog_builder/build.py $file $out_path | |
done | |
rm tmp.json | |
- name: Commit HTML Files | |
if: steps.check_changes.outputs.changed_files != '' | |
run: | | |
cd ${{ github.workspace }} | |
git add . | |
git config pull.rebase false | |
git commit -m "Add generated HTML files" | |
- name: Push changes | |
if: steps.check_changes.outputs.changed_files != '' | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |