.github/workflows/workflows-sync.yml #3
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
| name: Workflows Sync | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - master | |
| paths: | |
| - 'workflow-templates/**' | |
| - '.github/workflows/workflows-sync.yml' | |
| - 'sync_workflows.py' | |
| workflow_dispatch: | |
| inputs: | |
| all_accounts: | |
| description: 'Sync to all accounts (P4X-ng, HyperionGray, TeamHG-Memex, hyp3ri0n-ng)' | |
| required: false | |
| default: true | |
| type: boolean | |
| include_archived: | |
| description: 'Include archived repositories' | |
| required: false | |
| default: false | |
| type: boolean | |
| schedule: | |
| - cron: '0 6 * * *' | |
| jobs: | |
| sync: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install dependencies | |
| run: pip install requests | |
| - name: Sync workflow templates to all repositories | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GH_PAT || secrets.GITHUB_TOKEN }} | |
| run: | | |
| ALL_ACCOUNTS="true" | |
| INCLUDE_ARCHIVED="false" | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
| ALL_ACCOUNTS="${{ github.event.inputs.all_accounts }}" | |
| INCLUDE_ARCHIVED="${{ github.event.inputs.include_archived }}" | |
| fi | |
| if [ -z "${ALL_ACCOUNTS}" ]; then | |
| ALL_ACCOUNTS="true" | |
| fi | |
| if [ -z "${INCLUDE_ARCHIVED}" ]; then | |
| INCLUDE_ARCHIVED="false" | |
| fi | |
| ARCHIVED_FLAG="" | |
| if [ "${INCLUDE_ARCHIVED}" = "true" ]; then | |
| ARCHIVED_FLAG="--include-archived" | |
| fi | |
| if [ "${{ github.event_name }}" = "schedule" ] || [ "${ALL_ACCOUNTS}" = "true" ]; then | |
| echo "Syncing to all accounts: P4X-ng, HyperionGray, TeamHG-Memex, hyp3ri0n-ng" | |
| python sync_workflows.py --all-accounts \ | |
| ${ARCHIVED_FLAG} | |
| else | |
| echo "Syncing to P4X-ng only" | |
| python sync_workflows.py P4X-ng \ | |
| ${ARCHIVED_FLAG} | |
| fi | |
| - name: Summary | |
| if: always() | |
| run: | | |
| echo "## Workflow Sync Summary" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| ALL_ACCOUNTS="true" | |
| INCLUDE_ARCHIVED="false" | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
| ALL_ACCOUNTS="${{ github.event.inputs.all_accounts }}" | |
| INCLUDE_ARCHIVED="${{ github.event.inputs.include_archived }}" | |
| fi | |
| if [ -z "${ALL_ACCOUNTS}" ]; then | |
| ALL_ACCOUNTS="true" | |
| fi | |
| if [ -z "${INCLUDE_ARCHIVED}" ]; then | |
| INCLUDE_ARCHIVED="false" | |
| fi | |
| if [ "${{ github.event_name }}" = "schedule" ] || [ "${ALL_ACCOUNTS}" = "true" ]; then | |
| echo "**Accounts:** P4X-ng, HyperionGray, TeamHG-Memex, hyp3ri0n-ng (all accounts)" >> $GITHUB_STEP_SUMMARY | |
| else | |
| echo "**Accounts:** P4X-ng only" >> $GITHUB_STEP_SUMMARY | |
| fi | |
| echo "**Include archived:** ${INCLUDE_ARCHIVED}" >> $GITHUB_STEP_SUMMARY | |
| echo "**Trigger:** ${{ github.event_name }}" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "See logs above for detailed results." >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "> Note: The workflow succeeds as long as P4X-ng syncs successfully." >> $GITHUB_STEP_SUMMARY | |
| echo "> Failures in secondary accounts are expected if GH_PAT lacks access." >> $GITHUB_STEP_SUMMARY |