Merge branch 'main' of https://github.com/abap34/abap34.com #446
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 | |
paths: | |
- 'github/workflows/blog.yml' | |
- 'posts/**.md' | |
- 'config/**' | |
- 'assets/**' | |
- 'blog_builder/**' | |
- '.rebuild' | |
permissions: | |
contents: write | |
pages: write | |
id-token: write | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
- name: Setup Git | |
run: | | |
cd ${{ github.workspace }} | |
git config --global user.email "[email protected]" | |
git config --global user.name "GitHub Actions" | |
- name: Setup ALMO | |
run: | | |
git submodule update --init --recursive --remote | |
- name: Compile almo.cpp | |
run: | | |
cd ./almo | |
bash ./scripts/setup.sh | |
g++ -std=c++23 ./build/almo.cpp -o ./build/almo | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Get changed files | |
id: changed-files | |
uses: tj-actions/changed-files@v44 | |
with: | |
files: 'posts/**.md' | |
json: true | |
- name: Output changed files | |
run: echo "${{ steps.changed-files.outputs.all_changed_files }}" > changed_files.json | |
- name: Check need rebuild | |
id: check | |
uses: tj-actions/changed-files@v44 | |
with: | |
files: | | |
.github/workflows/blog.yml | |
config/** | |
assets/** | |
blog_builder/** | |
.rebuild | |
- name: Output need rebuild | |
if: ${{ steps.check.outputs.all_changed_files }} != "" | |
run: echo "REBUILD=true" >> $GITHUB_ENV | |
- name: Generate HTML | |
run: | | |
python3 blog_builder/build.py | |
- name: Update RSS | |
run: | | |
python3 blog_builder/rss.py | |
- name: Clean up | |
run: | | |
rm changed_files.json | |
rm tmp.json | |
- name: Check change | |
run: | | |
git diff-index --quiet HEAD || echo "CHANGE=true" >> $GITHUB_ENV | |
- name: Commit changes | |
run: | | |
git add . | |
git commit --allow-empty -m "Update blog" | |
- name: Push changes | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: main |