-
Notifications
You must be signed in to change notification settings - Fork 0
54 lines (48 loc) · 1.83 KB
/
sync.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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