-
Notifications
You must be signed in to change notification settings - Fork 5
Add CI automation for automatic Beman docs import #123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
neatudarius
wants to merge
43
commits into
bemanproject:main
Choose a base branch
from
neatudarius:test/sync-docs-workflow
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
93d67eb
Add CI automation for automatic Beman docs import
fc5c628
Tweaks
e428d0f
Tweaks
4310530
Tweaks
2d55b53
Tweaks
9f8201a
Test: Add PR testing support to sync-docs workflow
a9c4250
Add test mode for PR creation in sync-docs workflow
05d5b68
Use unique branch name format: website-weekly-docs-import-yyyy-mm-dd
3c0411a
Fix: Clean up beman directory and handle PR permission limitations
8b2cff9
Add workflow_dispatch input for test mode
ac9553a
Add debug info and repository settings check for workflow_dispatch
eacee61
Add support for Personal Access Token (PAT) to fix permission issues
9f02335
Improve PAT detection and instructions
b687a4f
Add better PAT detection and error messages
be37714
Clean up workflow: remove test/debug code, keep only production funct…
4d8fd67
Add back Show changes step with git status and git diff
11bccda
Add back pull_request trigger so workflow runs on PRs
50e26b5
Allow PR creation on PRs when PAT is available
54f5d12
Add repository_dispatch trigger for on-demand API triggering
bc70e5e
Update .github/workflows/sync-docs.yml
neatudarius cfc912d
Update .github/workflows/sync-docs.yml
neatudarius f075c11
Update .github/workflows/sync-docs.yml
neatudarius 9889e4f
Add SPDX identifier
4a29520
Fail fatal if PAT is missing when running on PRs
b393851
Add comprehensive debug section before Create Pull Request step
ee01cd9
Trigger workflow run
9721372
Move debug section earlier in workflow (after branch name generation)
c019525
Move Show changes step right after Generate branch name
03acade
Trigger workflow run to test GH_PAT
48033e2
Re-test workflow with GH_PAT secret
adbaa04
Trigger workflow run again
9bb9c56
Trigger workflow run
ee0dc4c
Update PR title to include date and review request
72d7bf2
Update PR: set assignee to neatudarius, add reviewers, and link to is…
1544255
Fix issue reference text: 'automatic docs import'
906bee9
Change 'Evergreen' to 'evergreen' (lowercase)
ed9c751
Simplify workflow: keep only schedule trigger, remove manual triggers…
692aef4
Add comprehensive documentation explaining workflow purpose, schedule…
e8494e6
Optimize checkout: change fetch-depth from 0 to 1 for better performance
5fd264f
Remove unnecessary cleanup step - GitHub Actions runners auto-cleanup…
29d3785
Make error message more generic: clarify repository Settings location
7adddaa
Make assignees and reviewers configurable via repository variables wi…
5d59528
Add workflow_dispatch and repository_dispatch triggers for manual tes…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,188 @@ | ||
| # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
|
||
| # Auto-sync Beman Documentation Workflow | ||
| # | ||
| # Purpose: | ||
| # This workflow automatically synchronizes documentation and images from the | ||
| # bemanproject/beman repository to the website repository. It ensures that | ||
| # the website always has the latest documentation content without manual | ||
| # intervention. | ||
| # | ||
| # When it runs: | ||
| # - Weekly on Mondays at 6:00 AM UTC (08:00–09:00 Romania time, depending on DST) | ||
| # - Runs automatically via GitHub Actions schedule (cron) | ||
| # - Can be triggered manually via workflow_dispatch (Actions tab → Run workflow) | ||
| # - Can be triggered via API using repository_dispatch with type "sync-docs" | ||
| # | ||
| # What it does: | ||
| # 1. Clones both the website and beman repositories | ||
| # 2. Runs the sync-docs.py script to copy documentation files and images | ||
| # 3. Cleans up temporary files (removes beman directory) | ||
| # 4. Creates a new branch with format: website-weekly-docs-import-YYYY-MM-DD | ||
| # 5. Creates a pull request with the synced changes | ||
| # | ||
| # Credentials: | ||
| # - Uses GITHUB_TOKEN (automatically provided by GitHub Actions) | ||
| # - The token has contents:write and pull-requests:write permissions | ||
| # | ||
| # Expected output: | ||
| # - A pull request titled: "Beman website weekly sync import (YYYY-MM-DD) - please review" | ||
| # - PR is assigned to neatudarius | ||
| # - PR has reviewers: neatudarius, RaduNichita, mguludag | ||
| # - PR is linked to issue #125 (evergreen issue: automatic docs import) | ||
| # - PR contains all synced documentation changes from bemanproject/beman | ||
|
|
||
| name: Auto-sync Beman Docs | ||
|
|
||
| on: | ||
| schedule: | ||
| - cron: '0 6 * * MON' # 08:00–09:00 Romania time (depending on DST) | ||
| workflow_dispatch: # Manual trigger for testing | ||
| repository_dispatch: # API trigger for on-demand runs | ||
| types: | ||
| - sync-docs | ||
|
|
||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| sync: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout website repo | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 1 | ||
|
|
||
| - name: Checkout beman repo | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| repository: bemanproject/beman | ||
| path: beman | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: '3.x' | ||
|
|
||
| - name: Run sync-docs.py | ||
| run: | | ||
| python3 scripts/sync-docs.py beman | ||
|
|
||
| - name: Generate branch name | ||
| id: branch-name | ||
| run: | | ||
| DATE_STR=$(date +%Y-%m-%d) | ||
| BRANCH_NAME="website-weekly-docs-import-$DATE_STR" | ||
| echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT | ||
| echo "date_str=$DATE_STR" >> $GITHUB_OUTPUT | ||
| echo "Generated branch name: $BRANCH_NAME" | ||
|
|
||
| - name: Show changes | ||
| run: | | ||
| echo "=== Changes detected ===" | ||
| git status | ||
| echo "" | ||
| echo "=== Diff ===" | ||
| git diff || echo "No changes detected" | ||
|
|
||
| - name: Debug workflow context and permissions | ||
| run: | | ||
| echo "=== Workflow Debug Information ===" | ||
| echo "" | ||
| echo "Event Information:" | ||
| echo " Event name: ${{ github.event_name }}" | ||
| echo " Ref: ${{ github.ref }}" | ||
| echo " Head ref: ${{ github.head_ref }}" | ||
| echo " Base ref: ${{ github.base_ref }}" | ||
| echo " SHA: ${{ github.sha }}" | ||
| echo "" | ||
| echo "Repository Information:" | ||
| echo " Repository: ${{ github.repository }}" | ||
| echo " Actor: ${{ github.actor }}" | ||
| echo " Workflow: ${{ github.workflow }}" | ||
| echo " Run ID: ${{ github.run_id }}" | ||
| echo " Run number: ${{ github.run_number }}" | ||
| echo "" | ||
| echo "Branch Information:" | ||
| echo " Generated branch: ${{ steps.branch-name.outputs.branch_name }}" | ||
| echo " Base branch: main" | ||
| echo "" | ||
| echo "Token Information:" | ||
| GH_PAT_VALUE="${{ secrets.GH_PAT }}" | ||
| if [ -n "$GH_PAT_VALUE" ] && [ "$GH_PAT_VALUE" != "" ]; then | ||
| echo " Token type: GH_PAT (Personal Access Token)" | ||
| echo " Token available: ✅ Yes" | ||
| echo " Token length: ${#GH_PAT_VALUE} characters" | ||
| else | ||
| echo " Token type: GITHUB_TOKEN" | ||
| echo " Token available: ⚠️ Limited permissions on PRs" | ||
| echo " GH_PAT secret: ❌ Not found or empty" | ||
| echo " Note: Add GH_PAT secret in repository Settings under Secrets and variables > Actions" | ||
| fi | ||
| echo "" | ||
| echo "Permissions:" | ||
| echo " Contents: write" | ||
| echo " Pull requests: write" | ||
| echo "" | ||
| echo "Git Status:" | ||
| git status --short || echo " (no changes or git error)" | ||
| echo "" | ||
| echo "=== End Debug Information ===" | ||
|
|
||
| - name: Prepare PR assignees and reviewers | ||
| id: pr-people | ||
| run: | | ||
| # Use repository variables if set, otherwise fall back to hardcoded defaults. | ||
| # These users are hardcoded as the primary website maintainers responsible | ||
| # for reviewing documentation sync PRs. If team membership changes, update | ||
| # repository variables DOC_SYNC_ASSIGNEES and DOC_SYNC_REVIEWERS instead of | ||
| # modifying this workflow file. | ||
| # Default assignee: neatudarius (primary website maintainer) | ||
| # Default reviewers: neatudarius, RaduNichita, mguludag (website maintainers) | ||
| # Get assignees and reviewers from vars or use defaults | ||
| if [ -n "${{ vars.DOC_SYNC_ASSIGNEES }}" ]; then | ||
| ASSIGNEES="${{ vars.DOC_SYNC_ASSIGNEES }}" | ||
| else | ||
| ASSIGNEES="neatudarius" | ||
| fi | ||
|
|
||
| if [ -n "${{ vars.DOC_SYNC_REVIEWERS }}" ]; then | ||
| REVIEWERS="${{ vars.DOC_SYNC_REVIEWERS }}" | ||
| else | ||
| REVIEWERS="neatudarius | ||
| RaduNichita | ||
| mguludag" | ||
| fi | ||
|
|
||
| echo "assignees<<EOF" >> $GITHUB_OUTPUT | ||
| echo "$ASSIGNEES" >> $GITHUB_OUTPUT | ||
| echo "EOF" >> $GITHUB_OUTPUT | ||
|
|
||
| echo "reviewers<<EOF" >> $GITHUB_OUTPUT | ||
| echo "$REVIEWERS" >> $GITHUB_OUTPUT | ||
| echo "EOF" >> $GITHUB_OUTPUT | ||
|
|
||
| echo "Using assignees: $ASSIGNEES" | ||
| echo "Using reviewers: $REVIEWERS" | ||
|
|
||
| - name: Create Pull Request | ||
| uses: peter-evans/create-pull-request@v6 | ||
| with: | ||
| token: ${{ secrets.GH_PAT || secrets.GITHUB_TOKEN }} | ||
| base: main | ||
| commit-message: "Auto-sync documentation from latest content of bemanproject/beman" | ||
| branch: ${{ steps.branch-name.outputs.branch_name }} | ||
| title: "Beman website weekly sync import (${{ steps.branch-name.outputs.date_str }}) - please review" | ||
| body: | | ||
| Automated sync of documentation and images from latest content of [bemanproject/beman](https://github.com/bemanproject/beman). | ||
|
|
||
| Related to: #125 - evergreen issue: automatic docs import | ||
| labels: | | ||
| sync | ||
| automation | ||
| author: "github-actions[bot] <github-actions[bot]@users.noreply.github.com>" | ||
neatudarius marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| assignees: ${{ steps.pr-people.outputs.assignees }} | ||
| reviewers: ${{ steps.pr-people.outputs.reviewers }} | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.