|
1 | | -name: Update Documentation |
2 | | - |
| 1 | +name: Sync libdebug gh-pages into main |
3 | 2 | on: |
| 3 | + push: |
| 4 | + branches: [main] |
4 | 5 | repository_dispatch: |
5 | | - types: ["update_docs"] |
| 6 | + types: [refresh_rolling] |
6 | 7 |
|
7 | 8 | jobs: |
8 | | - build: |
| 9 | + sync: |
| 10 | + if: github.actor != 'github-actions[bot]' |
9 | 11 | runs-on: ubuntu-latest |
10 | | - permissions: |
11 | | - contents: write |
| 12 | + permissions: { 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 |
| 15 | + - uses: actions/checkout@v4 |
| 16 | + with: { fetch-depth: 0 } |
31 | 17 |
|
32 | | - - name: Checkout libdebug |
| 18 | + - name: Checkout libdebug gh-pages |
33 | 19 | uses: actions/checkout@v4 |
| 20 | + env: |
| 21 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
34 | 22 | with: |
35 | | - repository: 'libdebug/libdebug' |
36 | | - path: 'libdebug' |
37 | | - ref: ${{ github.event.client_payload.sha }} |
| 23 | + repository: libdebug/libdebug |
| 24 | + ref: gh-pages |
| 25 | + path: libdebug-pages |
| 26 | + fetch-depth: 1 |
| 27 | + token: ${{ secrets.GITHUB_TOKEN }} |
38 | 28 |
|
39 | | - - name: Install libdebug |
| 29 | + - name: Sync files |
40 | 30 | run: | |
41 | | - cd libdebug |
42 | | - python -m pip install --upgrade . |
| 31 | + rsync -av libdebug-pages/ ./ \ |
| 32 | + --exclude '.git' --exclude '.github/**' |
| 33 | + rm -rf libdebug-pages |
43 | 34 |
|
44 | | - - name: Build documentation |
| 35 | + - name: Commit & push |
| 36 | + env: |
| 37 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
45 | 38 | run: | |
46 | | - cd libdebug/docs |
47 | | - ./regenerate_docs.sh |
48 | | - rm -r build/html/_static/__pycache__ |
49 | | -
|
50 | | - - name: Checkout docs |
51 | | - uses: actions/checkout@v4 |
52 | | - with: |
53 | | - path: 'docs' |
54 | | - |
55 | | - - name: Update files and commit changes |
56 | | - 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 |
| 39 | + git config user.name "github-actions[bot]" |
| 40 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 41 | + if git diff --quiet; then |
| 42 | + echo "✅ Nothing to commit." |
| 43 | + else |
| 44 | + git add --all |
| 45 | + git commit -m "docs: sync content from libdebug@gh-pages" |
| 46 | + git push origin HEAD |
| 47 | + fi |
0 commit comments