Skip to content

Commit ed2fb10

Browse files
authored
Merge pull request #62 from apify/feat/gh-57-content-sync
MDX conversion pipeline and Astro sync workflow
2 parents 1ec365e + b175471 commit ed2fb10

File tree

10 files changed

+1209
-10
lines changed

10 files changed

+1209
-10
lines changed
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: Sync Whitepaper to Astro (PR flow)
2+
3+
# Triggers on push to main when MD files or related assets change.
4+
on:
5+
push:
6+
branches:
7+
- main
8+
- feat/gh-57-content-sync
9+
paths:
10+
- '*.md'
11+
- 'pages/**/*.md'
12+
- '.github/workflows/sync-to-astro.yml'
13+
- 'scripts/**/*.py'
14+
workflow_dispatch: # also allows manual trigger from GitHub UI
15+
16+
env:
17+
TARGET_REPO: "apify/actor-whitepaper-web"
18+
TARGET_BRANCH: "sync/whitepaper-updates"
19+
20+
jobs:
21+
sync:
22+
name: Sync Whitepaper to Astro (PR flow)
23+
runs-on: ubuntu-latest
24+
permissions:
25+
contents: write # needed for pushing changes
26+
pull-requests: write # needed for creating PRs
27+
28+
steps:
29+
# Step 1: Clone the source repo (this repo).
30+
- name: Checkout source repo
31+
uses: actions/checkout@v4
32+
with:
33+
path: sync/source
34+
35+
# Step 2: Clone the target repo (Astro site).
36+
- name: Checkout target repo
37+
uses: actions/checkout@v4
38+
with:
39+
repository: ${{ env.TARGET_REPO }}
40+
path: sync/target
41+
token: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
42+
43+
# Step 3: Setup Python environment.
44+
- name: Setup Python
45+
uses: actions/setup-python@v4
46+
with:
47+
python-version: '3.11'
48+
cache: 'pip'
49+
cache-dependency-path: sync/source/requirements.txt
50+
51+
# Step 4: Install dependencies.
52+
- name: Install dependencies
53+
run: |
54+
python -m pip install --upgrade pip
55+
python -m pip install -r sync/source/requirements.txt
56+
cp sync/source/package.json . && npm install
57+
58+
# Step 5: Run the MD to MDX conversion script.
59+
- name: Run sync script
60+
run: python sync/source/scripts/md2mdx.py --source sync/source --target sync/target
61+
62+
# Step 6: Create or update PR with changes.
63+
- name: Create Pull Request
64+
env:
65+
GH_TOKEN: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
66+
run: |
67+
cd sync/target
68+
git status
69+
70+
# Create a unique branch name with timestamp.
71+
BRANCH_NAME="sync/whitepaper-updates-$(date +%Y%m%d-%H%M%S)"
72+
echo "Using branch: $BRANCH_NAME"
73+
74+
git config user.name "github-actions[bot]"
75+
git config user.email "github-actions[bot]@users.noreply.github.com"
76+
77+
git checkout -b "$BRANCH_NAME"
78+
79+
# Only create PR if there are changes.
80+
if [[ -n "$(git status --porcelain)" ]]; then
81+
echo "Changes detected:"
82+
git status --porcelain
83+
84+
git add .
85+
git commit -m "sync: Update MDX content from Whitepaper"
86+
if ! git push -f origin "$BRANCH_NAME"; then
87+
echo "Failed to push changes"
88+
exit 1
89+
fi
90+
91+
# Create the PR using GitHub CLI.
92+
gh pr create \
93+
--title "sync: Update MDX content from Whitepaper" \
94+
--body-file ../source/sync-pr-template.txt \
95+
--base main \
96+
--head "$BRANCH_NAME" \
97+
--label "sync" \
98+
--assignee ${{ github.actor }}
99+
else
100+
echo "No changes detected in git status --porcelain"
101+
echo "Full directory contents of src/content/pages:"
102+
ls -la src/content/pages/
103+
fi

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
11
.idea
22
node_modules
33
package-lock.json
4+
sync
5+
6+
# Python
7+
.venv
8+
__pycache__/
9+
*.py[cod]
10+
*$py.class
11+
.Python
12+
pip-log.txt
13+
pip-delete-this-directory.txt
14+
.pytest_cache/

0 commit comments

Comments
 (0)