chore: sync cascade-dev.yml from Template-Joomla [skip ci]
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
# Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
# FILE INFORMATION
|
||||
# DEFGROUP: MokoGIT.Workflow
|
||||
# INGROUP: MokoCLI.Release
|
||||
# BRIEF: Reset dev to main after each release (cascade). Moved out of auto-release Step 11.
|
||||
#
|
||||
# +========================================================================+
|
||||
# | CASCADE MAIN -> DEV |
|
||||
# +========================================================================+
|
||||
# | dev mirrors main and is reset on every release. |
|
||||
# | delete+recreate cannot run against a protected branch, so this |
|
||||
# | force-pushes main -> dev. The automation identity is force-push |
|
||||
# | allowlisted on dev via branch-protection.yml. |
|
||||
# | Runs AFTER the release workflow completes, so dev picks up the |
|
||||
# | fully version-bumped + changelog-promoted main (not the pre-bump |
|
||||
# | state). Force-push (not merge) => no version-file conflicts. |
|
||||
# +========================================================================+
|
||||
|
||||
name: "Cascade Main -> Dev"
|
||||
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: ["Universal: Build & Release"]
|
||||
types: [completed]
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: cascade-dev-${{ github.repository }}
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
cascade:
|
||||
name: Reset dev to main
|
||||
if: >-
|
||||
!startsWith(github.event.repository.name, 'Template-') &&
|
||||
(github.event_name == 'workflow_dispatch' ||
|
||||
github.event.workflow_run.conclusion == 'success')
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Force dev to main
|
||||
env:
|
||||
TOKEN: ${{ secrets.MOKOGIT_TOKEN }}
|
||||
SERVER: ${{ vars.GITEA_URL || 'https://git.mokoconsulting.tech' }}
|
||||
REPO: ${{ github.repository }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
git init -q sync && cd sync
|
||||
git config user.email "mokogit-actions[bot]@mokoconsulting.tech"
|
||||
git config user.name "mokogit-actions[bot]"
|
||||
git remote add origin "https://x-access-token:${TOKEN}@${SERVER#https://}/${REPO}.git"
|
||||
git fetch -q --depth=1 origin main
|
||||
|
||||
if git ls-remote --exit-code --heads origin dev >/dev/null 2>&1; then
|
||||
# dev exists -> force it to match main (dev is a mirror of main)
|
||||
git push --force origin FETCH_HEAD:refs/heads/dev
|
||||
echo "dev reset to main" >> "$GITHUB_STEP_SUMMARY"
|
||||
else
|
||||
# dev missing (e.g. renamed to rc mid-cycle) -> recreate from main
|
||||
git push origin FETCH_HEAD:refs/heads/dev
|
||||
echo "dev created from main" >> "$GITHUB_STEP_SUMMARY"
|
||||
fi
|
||||
Reference in New Issue
Block a user