|
1 | | -name: Update Documentation |
| 1 | +name: Sync libdebug gh-pages into main |
2 | 2 |
|
3 | 3 | on: |
4 | | - repository_dispatch: |
5 | | - types: ["update_docs"] |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
6 | 7 |
|
7 | 8 | jobs: |
8 | | - build: |
| 9 | + sync: |
9 | 10 | runs-on: ubuntu-latest |
10 | 11 | permissions: |
11 | 12 | contents: write |
12 | 13 |
|
13 | 14 | steps: |
14 | | - - name: Set up Python |
15 | | - uses: actions/setup-python@v5 |
16 | | - with: |
17 | | - python-version: 3.12 |
18 | | - |
19 | | - - name: Install documentation dependencies |
20 | | - run: | |
21 | | - python -m pip install --upgrade pip |
22 | | - python -m pip install --upgrade setuptools |
23 | | - python -m pip install --upgrade Sphinx |
24 | | - python -m pip install --upgrade pydata-sphinx-theme |
25 | | - python -m pip install --upgrade sphinx_code_tabs |
26 | | -
|
27 | | - - name: Install libdebug dependencies |
28 | | - run: | |
29 | | - sudo apt-get update |
30 | | - sudo apt-get install -y --no-install-recommends libdwarf-dev libelf-dev libiberty-dev linux-headers-generic libc6-dbg |
31 | | -
|
32 | | - - name: Checkout libdebug |
| 15 | + - name: Checkout this repo |
33 | 16 | uses: actions/checkout@v4 |
34 | 17 | with: |
35 | | - repository: 'libdebug/libdebug' |
36 | | - path: 'libdebug' |
37 | | - ref: ${{ github.event.client_payload.sha }} |
| 18 | + fetch-depth: 0 |
38 | 19 |
|
39 | | - - name: Install libdebug |
40 | | - run: | |
41 | | - cd libdebug |
42 | | - python -m pip install --upgrade . |
43 | | -
|
44 | | - - name: Build documentation |
45 | | - run: | |
46 | | - cd libdebug/docs |
47 | | - ./regenerate_docs.sh |
48 | | - rm -r build/html/_static/__pycache__ |
49 | | -
|
50 | | - - name: Checkout docs |
| 20 | + - name: Checkout libdebug gh-pages |
51 | 21 | uses: actions/checkout@v4 |
52 | 22 | with: |
53 | | - path: 'docs' |
| 23 | + repository: libdebug/libdebug |
| 24 | + ref: gh-pages |
| 25 | + path: libdebug-pages |
| 26 | + fetch-depth: 1 |
54 | 27 |
|
55 | | - - name: Update files and commit changes |
| 28 | + - name: Sync files from gh-pages |
56 | 29 | run: | |
57 | | - cd libdebug |
58 | | - export LIBDEBUG_VERSION=$(python -m setup --version 2>/dev/null) |
59 | | - cd .. |
60 | | - export OLD_VERSION=$(cat docs/latest/version) |
61 | | - echo "Removing docs/archive/$OLD_VERSION" |
62 | | - rm -rf "docs/archive/$OLD_VERSION" |
63 | | - mv docs/latest "docs/archive/$OLD_VERSION" |
64 | | - mv libdebug/docs/build/html docs/latest |
65 | | - echo $LIBDEBUG_VERSION > docs/latest/version |
66 | | - cd docs |
67 | | - git config --local user.email "github-actions[bot]@users.noreply.github.com" |
68 | | - git config --local user.name "github-actions[bot]" |
69 | | - git tag -f $LIBDEBUG_VERSION |
70 | | - git add archive/$OLD_VERSION |
71 | | - git commit -a -m "Autorefresh Documentation" |
72 | | - |
73 | | - - name: Push changes |
74 | | - uses: ad-m/github-push-action@master |
75 | | - with: |
76 | | - directory: 'docs' |
77 | | - force: true |
78 | | - tags: true |
| 30 | + # copy all files over, but leave existing files intact and skip any .git dirs |
| 31 | + rsync -av libdebug-pages/ . \ |
| 32 | + --exclude '.github/**' \ |
| 33 | + --exclude '.git' \ |
| 34 | + --exclude '.git/**' |
| 35 | +
|
| 36 | + - name: Commit & push changes |
| 37 | + env: |
| 38 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 39 | + run: | |
| 40 | + git config user.name "github-actions[bot]" |
| 41 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 42 | +
|
| 43 | + if git diff --quiet; then |
| 44 | + echo "✅ Nothing to commit." |
| 45 | + else |
| 46 | + git add --all |
| 47 | + git commit -m "chore: sync content from libdebug/libdebug@gh-pages" |
| 48 | + git push origin main |
| 49 | + fi |
0 commit comments