Skip to content

Add CI automation for automatic Beman docs import #35

Add CI automation for automatic Beman docs import

Add CI automation for automatic Beman docs import #35

Workflow file for this run

# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
name: Auto-sync Beman Docs
on:
push:
branches:
- main
pull_request:
workflow_call:
workflow_dispatch:
repository_dispatch:
types:
- sync-docs
schedule:
- cron: '0 6 * * MON' # 08:00–09:00 Romania time (depending on DST)
permissions:
contents: write
pull-requests: write
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Checkout website repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- 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: Clean up beman directory
run: |
rm -rf 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 at: Settings > 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: Check if PAT is available for PR creation
id: check-pat
run: |
GH_PAT_VALUE="${{ secrets.GH_PAT }}"
if [ -n "$GH_PAT_VALUE" ] && [ "$GH_PAT_VALUE" != "" ]; then
echo "pat_available=true" >> $GITHUB_OUTPUT
echo "✅ GH_PAT secret is available - will use it for PR creation"
echo " Token length: ${#GH_PAT_VALUE} characters"
else
echo "pat_available=false" >> $GITHUB_OUTPUT
if [ "${{ github.event_name }}" == "pull_request" ]; then
echo "❌ FATAL: GH_PAT secret is required when running on pull_request events"
echo " Add GH_PAT secret at: Settings > Secrets and variables > Actions"
echo " Current value: [empty or not set]"
exit 1
else
echo "⚠️ GH_PAT secret not found - using GITHUB_TOKEN"
fi
fi
- name: Create Pull Request
if: github.event_name != 'pull_request' || steps.check-pat.outputs.pat_available == 'true'
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>"
assignees: |
neatudarius
reviewers: |
neatudarius
RaduNichita
mguludag