Skip to content

1. [AUTO] Generate Content & Deploy #10

1. [AUTO] Generate Content & Deploy

1. [AUTO] Generate Content & Deploy #10

name: 1. [AUTO] Generate Content & Deploy
# --- PERMISSIES VOOR DE HELE WORKFLOW ---
permissions:
contents: write # Toestemming om content te committen
pages: write # Toestemming om naar GitHub Pages te schrijven
id-token: write # Toestemming voor authenticatie met de deploy-actie
on:
schedule:
# Draait om 03:00 UTC op de eerste dag van elke maand
- cron: '0 3 1 * *'
workflow_dispatch:
inputs:
skip_content_generation:
description: 'Sla de content generatie stappen over.'
required: false
type: boolean
default: false
jobs:
# JOB 1: Genereer alle content en data bestanden
generate-content:
runs-on: ubuntu-latest
if: |
github.event_name == 'schedule' ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.skip_content_generation != 'true')
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run Content Generation Pipeline
env:
SITE_BASE_URL: "https://kareltestspecial.github.io/Vegan-BioTech-Report/"
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
run: python3 pipeline/run_pipeline.py
- name: Commit and Push Generated Content
run: |
git config user.name "GitHub Actions Bot"
git config user.email "actions@github.com"
git add .
if ! git diff --staged --quiet; then
git commit -m "feat(content): Add generated content from workflow run"
git pull --rebase origin main
git push https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} HEAD:main
fi
- name: Generate Images with Gemini
env:
GEMINI_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
run: python pipeline/generate_images.py
- name: Commit and Push Generated Images
run: |
git config user.name "GitHub Actions Bot"
git config user.email "actions@github.com"
git add .
if ! git diff --staged --quiet; then
git commit -m "feat(content): Add generated images from workflow run"
git pull --rebase origin main
git push https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} HEAD:main
fi
# JOB 2: Build en deploy
build-and-deploy:
runs-on: ubuntu-latest
needs: generate-content
if: always()
permissions:
contents: read
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: true
ref: main
- name: Setup Hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: '0.153.1'
extended: true
- name: Setup Pages
id: pages
uses: actions/configure-pages@v5
- name: Build with Hugo
run: hugo --buildFuture --cleanDestinationDir --minify --baseURL ${{ steps.pages.outputs.base_url }}
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./public
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
# JOB 3: Stuur email notificatie
send-email-notification:
runs-on: ubuntu-latest
needs: [generate-content, build-and-deploy]
if: always()
steps:
- name: Send email notification
uses: dawidd6/action-send-mail@v3
with:
server_address: smtp.gmail.com
server_port: 465
username: karel.test.special@gmail.com
password: ${{ secrets.MAIL_PASSWORD }}
subject: "VeganTechReport Workflow Status: ${{ needs.build-and-deploy.result }}"
body: |
The monthly content generation and deployment workflow has completed.
- Generate Content Job: ${{ needs.generate-content.result }}
- Build and Deploy Job: ${{ needs.build-and-deploy.result }}
Check the latest run for more details: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
to: karel.test.special@gmail.com
from: "GitHub Actions (VeganTechReport)"