Generate SCP Entry #43
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 SCP Entry | |
on: | |
schedule: | |
- cron: "0 0 * * *" # Run daily at midnight UTC | |
workflow_dispatch: # Allow manual trigger | |
jobs: | |
generate-and-deploy: | |
permissions: write-all | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: "3.10" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r scp/requirements.txt | |
- name: Run SCP generator | |
run: python scp/scp-runner.py | |
env: | |
DOTTXT_API_KEY: ${{ secrets.DOTTXT_API_KEY }} | |
DOTTXT_API_HOST: ${{ secrets.DOTTXT_API_HOST }} | |
- name: Configure Git | |
run: | | |
git config user.name github-actions[bot] | |
git config user.email 41898282+github-actions[bot]@users.noreply.github.com | |
- name: Create and switch to gh-pages branch | |
run: | | |
git fetch origin gh-pages | |
# copy the generator script to a local directory | |
cp scp/generate_index.py . | |
git checkout -B gh-pages origin/gh-pages | |
- name: Copy generated files and index generator | |
run: | | |
mkdir -p scp/entries | |
cp -R entries/* scp/entries/ | |
- name: Generate index | |
run: | | |
cp generate_index.py scp/ | |
cd scp/ | |
python generate_index.py | |
- name: Commit and push changes | |
run: | | |
git add -f scp/entries scp/index.html | |
git commit -m "Add new SCP entry and update index" || echo "No changes to commit" | |
git push origin gh-pages || git pull --rebase origin gh-pages && git push origin gh-pages |