Generate Course Cover #411
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: Generate Course Cover | |
on: | |
workflow_dispatch: | |
inputs: | |
course_alias: | |
description: "Course alias (e.g. html-for-beginners)" | |
required: true | |
course_lang: | |
description: "Course language (e.g. en, zh)" | |
required: true | |
default: "en" | |
overwrite: | |
description: "Overwrite existing cover (true/false)" | |
required: false | |
default: "false" | |
type: boolean | |
concurrency: | |
group: generate-course-cover | |
cancel-in-progress: false | |
jobs: | |
generate: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.x" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install requests playwright rich click | |
playwright install chromium | |
- name: Generate course cover | |
env: | |
FREEPIK_API_KEY: ${{ secrets.FREEPIK_API_KEY }} | |
run: python scripts/generate_cover.py "${{ github.event.inputs.course_alias }}" "${{ github.event.inputs.course_lang }}" ${{ (github.event.inputs.overwrite == 'true') && '--overwrite' || '--no-overwrite' }} | |
- name: Commit and push changes | |
run: | | |
git config --local user.email "action@github.com" | |
git config --local user.name "GitHub Action" | |
git add . | |
if [ -n "$(git status --porcelain)" ]; then | |
echo "Changes detected, committing..." | |
git commit -m "chore: update course cover for ${{ github.event.inputs.course_alias }}" | |
git pull --rebase origin master | |
git push | |
else | |
echo "No changes to commit" | |
fi |