Acceptance (end-to-end TCP) / End-to-end TCP acceptance (push) Canceled after 0s
CSharp Server Gate / Repository policy, C# build and test (push) Canceled after 0s
GNS Transport Bridge / Linux native GNS bridge (push) Canceled after 0s
Host GUI (Avalonia) / Build Avalonia host (push) Canceled after 0s
Acceptance (end-to-end TCP) / End-to-end TCP acceptance (pull_request) Canceled after 0s
CSharp Server Gate / Repository policy, C# build and test (pull_request) Canceled after 0s
GNS Transport Bridge / Linux native GNS bridge (pull_request) Canceled after 0s
Host GUI (Avalonia) / Build Avalonia host (pull_request) Canceled after 0s
GitHub-hosted runners are billing-blocked for this org, so the hosted open-gitea-pr job never started (empty logs, immediate failure on every push to main). Retarget it to [self-hosted, Linux, X64] like the other workflows; the runner has LAN access to the Gitea host, and this workflow only fires on push to main, so it never runs untrusted fork PR code.
71 lines
3.1 KiB
YAML
71 lines
3.1 KiB
YAML
name: Open Gitea PR on merge to main
|
|
|
|
# When main changes on GitHub (i.e. after a PR is merged here), push those
|
|
# commits to a branch on Gitea and open a pull request there, so the same
|
|
# change can be reviewed and landed on the Gitea side. One-way: GitHub -> Gitea.
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
open-gitea-pr:
|
|
# GitHub-hosted runners are billing-blocked for this org, so the hosted job
|
|
# never started. Run on the self-hosted runner, which also has LAN access to
|
|
# the Gitea host. This workflow only fires on push to main (never on PRs from
|
|
# forks), so it is safe on the private runner.
|
|
runs-on: [self-hosted, Linux, X64]
|
|
steps:
|
|
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Push main to Gitea and open a pull request
|
|
env:
|
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
|
GITEA_HOST: git.zambazosmedia.group
|
|
GITEA_USER: nomad
|
|
GITEA_REPO: Commonwealth-Online/Commonwealth-Online-Server
|
|
SYNC_BRANCH: sync/from-github
|
|
run: |
|
|
set -euo pipefail
|
|
if [ -z "${GITEA_TOKEN:-}" ]; then
|
|
echo "::error::Missing GITEA_TOKEN secret. Add a Gitea access token as a"
|
|
echo "::error::repository secret named GITEA_TOKEN (Settings -> Secrets and"
|
|
echo "::error::variables -> Actions -> New repository secret)."
|
|
exit 1
|
|
fi
|
|
|
|
git config user.name "github-sync"
|
|
git config user.email "github-sync@users.noreply.github.com"
|
|
|
|
# Mirror the current main onto a dedicated Gitea branch. Force is safe:
|
|
# this branch is owned by the automation and only ever tracks GitHub main.
|
|
git remote add gitea "https://${GITEA_USER}:${GITEA_TOKEN}@${GITEA_HOST}/${GITEA_REPO}.git"
|
|
git push -f gitea "HEAD:refs/heads/${SYNC_BRANCH}"
|
|
|
|
# Open a PR on Gitea: sync/from-github -> main. If one is already open,
|
|
# the push above has already updated it, so a 409 is success too.
|
|
http_code=$(curl -sS -o /tmp/gitea_pr.json -w "%{http_code}" -X POST \
|
|
"https://${GITEA_HOST}/api/v1/repos/${GITEA_REPO}/pulls" \
|
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{\"title\":\"Sync from GitHub main\",\"head\":\"${SYNC_BRANCH}\",\"base\":\"main\",\"body\":\"Automated: GitHub main was updated. Review and merge to land it on Gitea.\"}")
|
|
|
|
echo "Gitea pulls API returned HTTP ${http_code}"
|
|
cat /tmp/gitea_pr.json || true
|
|
echo
|
|
|
|
if [ "${http_code}" = "201" ]; then
|
|
echo "Opened a new Gitea pull request."
|
|
elif [ "${http_code}" = "409" ] || grep -qiE "already exist|issue_exist" /tmp/gitea_pr.json; then
|
|
echo "A Gitea PR from ${SYNC_BRANCH} is already open; it now has the latest commits."
|
|
else
|
|
echo "::warning::Unexpected Gitea response (${http_code}). The branch was pushed;"
|
|
echo "::warning::open the PR manually on Gitea if it did not appear."
|
|
fi
|