Skip to content

Sync Content

Sync Content #185

Workflow file for this run

name: Sync Content
on:
schedule:
- cron: '0 5 * * *'
workflow_dispatch:
jobs:
sync:
runs-on: ubuntu-latest
# Run only on main branch in upstream repo.
if: ${{ github.repository == 'scientific-python-translations/scipy.org-translations' && github.ref == 'refs/heads/main' }}
steps:
- name: Set the branch name with more granularity
run: echo "BRANCH_NAME=updates-$(date +%Y-%m-%d-%H-%M-%S)" >> $GITHUB_ENV
- name: Checkout scipy.org
uses: actions/checkout@v4
with:
repository: 'scipy/scipy.org'
path: 'scipy.org'
ref: 'main'
- name: Checkout scipy.org-translations
uses: actions/checkout@v4
with:
path: 'scipy.org-translations'
ref: 'main'
- name: Sync the website content
run: |
rsync -av --delete scipy.org/content/en scipy.org-translations/content/
cd scipy.org-translations
git checkout -b ${{ env.BRANCH_NAME }}
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions"
git add .
# Only proceed to commit if there are changes
if git diff --staged --quiet; then
echo "No changes to commit."
echo "CONTENT_CHANGED=false" >> $GITHUB_ENV
else
git commit -m "Update website content"
echo "CONTENT_CHANGED=true" >> $GITHUB_ENV
git push -u origin ${{ env.BRANCH_NAME }}
fi
- name: Create Pull Request
if: env.CONTENT_CHANGED == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run:
gh pr create --base main --head ${{ env.BRANCH_NAME }} --title "Update source content" --body "Automated update of scipy.org content."
working-directory: ./scipy.org-translations