Skip to content

Simplify gh action

Simplify gh action #52

Workflow file for this run

name: Generate eBook and Deploy to GitHub Pages
on:
push:
branches:
- main
pull_request:
branches:
- main
permissions:
contents: write
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
extensions: gd, zip, mbstring
coverage: none
- name: Cache Composer packages
uses: actions/cache@v4
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install dependencies
run: composer install --prefer-dist --no-progress --optimize-autoloader
- name: Generate eBooks (All Formats)
run: |
composer run pdf
composer run pdf-dark
composer run epub
composer run html
composer run sample
composer run sample-dark
- name: Check for changes
id: verify-changed-files
run: |
if git diff --quiet HEAD -- ebook/en/export/ index.html; then
echo "changed=false" >> $GITHUB_OUTPUT
else
echo "changed=true" >> $GITHUB_OUTPUT
fi
- name: Commit and push all changes (including GitHub Pages HTML)
if: steps.verify-changed-files.outputs.changed == 'true' && github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
git config --local user.email "bobby@bobbyiliev.com"
git config --local user.name "Bobby Iliev"
git add ebook/en/export/ index.html
git commit -m "🤖 Auto-update eBook files and GitHub Pages [skip ci]" || exit 0
git push
- name: Upload eBook artifacts
uses: actions/upload-artifact@v4
with:
name: ebooks-${{ github.sha }}
path: |
ebook/en/export/*.pdf
ebook/en/export/*.epub
ebook/en/export/*.html
index.html
retention-days: 90