Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 109 additions & 0 deletions .github/workflows/blog-syndication.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: Syndicate Blog Posts

on:
schedule:
# Daily at 13:00 UTC. Runs from the default branch only, per GitHub's cron rules.
- cron: '0 13 * * *'
workflow_dispatch:
inputs:
dry_run:
description: 'Skip API calls and only print what would happen.'
type: boolean
default: false

permissions:
contents: write

concurrency:
group: blog-syndication
cancel-in-progress: false

jobs:
syndicate:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
# Token with write scope so the post-run commit can push the state file.
token: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Run API syndication script
id: syndicate_api
env:
DEVTO_API_KEY: ${{ secrets.DEVTO_API_KEY }}
HASHNODE_TOKEN: ${{ secrets.HASHNODE_TOKEN }}
HASHNODE_PUBLICATION_ID: ${{ secrets.HASHNODE_PUBLICATION_ID }}
run: |
set -euo pipefail
if [ "${{ inputs.dry_run }}" = "true" ]; then
python3 scripts/website/syndicate_blog_posts.py --dry-run
else
python3 scripts/website/syndicate_blog_posts.py
fi

- name: Detect browser-syndication credentials
id: browser_creds
env:
FOOJAY_USER: ${{ secrets.FOOJAY_USER }}
HACKERNOON_USER: ${{ secrets.HACKERNOON_USER }}
DZONE_STORAGE_STATE: ${{ secrets.DZONE_STORAGE_STATE }}
MEDIUM_STORAGE_STATE: ${{ secrets.MEDIUM_STORAGE_STATE }}
run: |
if [ -n "${FOOJAY_USER}" ] || [ -n "${HACKERNOON_USER}" ] || [ -n "${DZONE_STORAGE_STATE}" ] || [ -n "${MEDIUM_STORAGE_STATE}" ]; then
echo "any_configured=true" >> "${GITHUB_OUTPUT}"
else
echo "any_configured=false" >> "${GITHUB_OUTPUT}"
fi

- name: Install Playwright dependencies
if: ${{ steps.browser_creds.outputs.any_configured == 'true' }}
run: |
set -euo pipefail
pip install playwright
playwright install --with-deps chromium

- name: Run browser syndication script
if: ${{ steps.browser_creds.outputs.any_configured == 'true' }}
env:
FOOJAY_USER: ${{ secrets.FOOJAY_USER }}
FOOJAY_PASSWORD: ${{ secrets.FOOJAY_PASSWORD }}
HACKERNOON_USER: ${{ secrets.HACKERNOON_USER }}
HACKERNOON_PASSWORD: ${{ secrets.HACKERNOON_PASSWORD }}
DZONE_STORAGE_STATE: ${{ secrets.DZONE_STORAGE_STATE }}
MEDIUM_STORAGE_STATE: ${{ secrets.MEDIUM_STORAGE_STATE }}
run: |
set -euo pipefail
if [ "${{ inputs.dry_run }}" = "true" ]; then
python3 scripts/website/syndicate_browser_posts.py --dry-run
else
python3 scripts/website/syndicate_browser_posts.py
fi

- name: Upload syndication screenshots on failure
if: ${{ always() && hashFiles('docs/website/reports/syndication-screenshots/**/*.png') != '' }}
uses: actions/upload-artifact@v4
with:
name: syndication-screenshots
path: docs/website/reports/syndication-screenshots/
if-no-files-found: ignore
retention-days: 14

- name: Commit updated syndication state
if: ${{ inputs.dry_run != true }}
run: |
set -euo pipefail
if git diff --quiet -- scripts/website/syndication-state.json; then
echo "No state changes to commit."
exit 0
fi
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
git add scripts/website/syndication-state.json
git commit -m "ci: record blog syndication results"
git push
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
**/dist/*
*.zip
CodenameOneDesigner/src/version.properties
*-storage-state.json
*-storage-state.*.json
/Ports/iOSPort/build/
/Ports/iOSPort/dist/
Ports/iOSPort/nbproject/private/private.xml
Expand Down
2 changes: 2 additions & 0 deletions docs/website/reports/syndication-screenshots/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.png
!.gitignore
Loading
Loading