CV and website workflow #538
This file contains hidden or 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: CV and website workflow | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: [ master ] | |
| paths: | |
| - CV.tex | |
| - database.py | |
| - makeCV.py | |
| - .github/workflows/CV_website.yml | |
| schedule: | |
| - cron: '18 1 * * *' | |
| jobs: | |
| CV_website: | |
| runs-on: ubuntu-latest | |
| container: | |
| image: ghcr.io/${{ github.repository_owner }}/cv-ci:latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout CV | |
| uses: actions/checkout@v4 | |
| with: | |
| path: CV | |
| - name: Checkout website | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: dgerosa/website | |
| token: ${{ secrets.PERSONAL_TOKEN }} | |
| path: website | |
| - name: Init workflow log | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| : > CV/workflow.txt | |
| - name: Generate CV inputs (citations, markdown, tex) | |
| working-directory: CV | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| { | |
| echo "================================================================================" | |
| echo "STEP START: Generate CV inputs (makeCV.py)" | |
| echo "TIME (UTC): $(date -u +\"%Y-%m-%dT%H:%M:%SZ\")" | |
| echo "================================================================================" | |
| python -c 'import os; t=os.getenv("ADS_TOKEN",""); print("ADS_TOKEN set:", bool(t), "len:", len(t))' | |
| python -u makeCV.py | |
| } 2>&1 | tee -a workflow.txt | |
| env: | |
| ADS_TOKEN: ${{ secrets.ADS_TOKEN }} | |
| - name: Upload blogpost templates | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: blogpost-templates | |
| path: CV/temp | |
| if-no-files-found: ignore | |
| - name: Compile latex | |
| working-directory: CV | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| { | |
| echo "================================================================================" | |
| echo "STEP START: Compile latex" | |
| echo "TIME (UTC): $(date -u +\"%Y-%m-%dT%H:%M:%SZ\")" | |
| echo "================================================================================" | |
| for f in CV CVshort publist talklist; do | |
| pdflatex "$f".tex | |
| done | |
| } 2>&1 | tee -a workflow.txt | |
| - name: Copy files | |
| working-directory: CV | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| { | |
| echo "================================================================================" | |
| echo "STEP START: Copy files" | |
| echo "TIME (UTC): $(date -u +\"%Y-%m-%dT%H:%M:%SZ\")" | |
| echo "================================================================================" | |
| cp CV.pdf DavideGerosa_fullCV.pdf | |
| cp CVshort.pdf DavideGerosa_shortCV.pdf | |
| cp publist.pdf DavideGerosa_publist.pdf | |
| cp talklist.pdf DavideGerosa_talklist.pdf | |
| cp _citations.md _group.md _publications.md _talks.md ../website/_pages/ | |
| } 2>&1 | tee -a workflow.txt | |
| - name: Commit and push CV updates | |
| working-directory: CV | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| { | |
| echo "================================================================================" | |
| echo "STEP START: Commit and push CV updates" | |
| echo "TIME (UTC): $(date -u +\"%Y-%m-%dT%H:%M:%SZ\")" | |
| echo "================================================================================" | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add -A | |
| # workflow.txt is a run log (uploaded as an artifact) and should not be committed. | |
| git reset -q workflow.txt || true | |
| git commit -m "CV update from workflow" || echo "No changes" | |
| git push | |
| } 2>&1 | tee -a workflow.txt | |
| - name: Commit and push website updates | |
| working-directory: website | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| { | |
| echo "================================================================================" | |
| echo "STEP START: Commit and push website updates" | |
| echo "TIME (UTC): $(date -u +\"%Y-%m-%dT%H:%M:%SZ\")" | |
| echo "================================================================================" | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add -A | |
| git commit -m "Website update from workflow" || echo "No changes" | |
| git push | |
| } 2>&1 | tee -a ../CV/workflow.txt | |
| - name: Publish CV release | |
| working-directory: CV | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| { | |
| echo "================================================================================" | |
| echo "STEP START: Publish CV release" | |
| echo "TIME (UTC): $(date -u +\"%Y-%m-%dT%H:%M:%SZ\")" | |
| echo "================================================================================" | |
| TAG=$(date +"%Y-%m-%d-%H-%M") | |
| FILES=$(ls DavideGerosa_*.pdf 2>/dev/null || true) | |
| gh release create "$TAG" $FILES --notes "Automated CV update" | |
| } 2>&1 | tee -a workflow.txt | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Upload workflow log artifact | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: workflow-log | |
| path: CV/workflow.txt | |
| if-no-files-found: error | |
| - name: Zip blogpost templates for email | |
| if: always() | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| python - <<'PY' | |
| import os | |
| import zipfile | |
| from pathlib import Path | |
| root = Path("CV") | |
| src = root / "temp" | |
| dst = root / "blogpost-templates.zip" | |
| dst.parent.mkdir(parents=True, exist_ok=True) | |
| with zipfile.ZipFile(dst, "w", compression=zipfile.ZIP_DEFLATED) as zf: | |
| if src.exists(): | |
| for p in src.rglob("*"): | |
| if p.is_file(): | |
| zf.write(p, p.relative_to(root)) | |
| else: | |
| zf.writestr("temp/README.txt", "CV/temp did not exist in this run.\n") | |
| print(f"Wrote {dst}") | |
| PY | |
| - name: Prepare email body | |
| if: always() | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| { | |
| echo "Repo: ${{ github.repository }}" | |
| echo "Workflow: ${{ github.workflow }}" | |
| echo "Run: ${{ github.run_id }}" | |
| echo "Job: ${{ github.job }}" | |
| echo "Status: ${{ job.status }}" | |
| echo | |
| echo "=== Full workflow.txt ===" | |
| cat CV/workflow.txt || true | |
| } > CV/email_body.txt | |
| - name: Decide whether to send email | |
| if: always() | |
| id: mail_enabled | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| if [ -n "${SMTP_PASSWORD:-}" ]; then | |
| echo "enabled=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "enabled=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| env: | |
| SMTP_PASSWORD: ${{ secrets.SMTP_PASSWORD }} | |
| - name: Email workflow log | |
| if: ${{ always() && steps.mail_enabled.outputs.enabled == 'true' }} | |
| uses: dawidd6/action-send-mail@v3 | |
| with: | |
| server_address: smtp.gmail.com | |
| server_port: 465 | |
| secure: true | |
| username: davide.gerosa@gmail.com | |
| password: ${{ secrets.SMTP_PASSWORD }} | |
| subject: "[dgerosa/CV] CV_website.yml: ${{ job.status }}" | |
| to: davide.gerosa+github@gmail.com | |
| from: davide.gerosa+github@gmail.com | |
| body: file://CV/email_body.txt | |
| attachments: CV/blogpost-templates.zip |