76 lines
2.5 KiB
YAML
76 lines
2.5 KiB
YAML
name: Sync Mirror to GitCode
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
release:
|
|
types: [published, released, edited, prereleased]
|
|
workflow_dispatch:
|
|
inputs:
|
|
tag:
|
|
description: "Specific release tag to sync (empty = latest app release + all runtime-* releases)"
|
|
required: false
|
|
default: ""
|
|
sync_releases:
|
|
description: "Also sync Release metadata and assets to GitCode"
|
|
type: boolean
|
|
default: true
|
|
|
|
concurrency:
|
|
group: sync-gitcode
|
|
cancel-in-progress: false
|
|
|
|
jobs:
|
|
sync:
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
GITCODE_REPO: Nwflower/Reims-Go
|
|
GITCODE_USER: Nwflower
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Push main branch and tags to GitCode
|
|
env:
|
|
GITCODE_TOKEN: ${{ secrets.GITCODE_TOKEN }}
|
|
run: |
|
|
set -euo pipefail
|
|
if [ -z "$GITCODE_TOKEN" ]; then
|
|
echo "GITCODE_TOKEN secret is not configured; skipping."
|
|
exit 0
|
|
fi
|
|
git fetch --tags origin
|
|
# Use GIT_ASKPASS so the token never appears in URLs or process argv.
|
|
askpass="$(mktemp)"
|
|
chmod 700 "$askpass"
|
|
cat > "$askpass" <<'EOF'
|
|
#!/bin/sh
|
|
case "$1" in
|
|
*Username*) printf '%s\n' "$GITCODE_USER" ;;
|
|
*) printf '%s\n' "$GITCODE_TOKEN" ;;
|
|
esac
|
|
EOF
|
|
trap 'rm -f "$askpass"' EXIT
|
|
GIT_TERMINAL_PROMPT=0 GIT_ASKPASS="$askpass" git -c credential.helper= push "https://gitcode.com/${GITCODE_REPO}.git" HEAD:refs/heads/main
|
|
GIT_TERMINAL_PROMPT=0 GIT_ASKPASS="$askpass" git -c credential.helper= push "https://gitcode.com/${GITCODE_REPO}.git" --tags
|
|
|
|
- name: Sync Release and assets to GitCode
|
|
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && inputs.sync_releases)
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
GITCODE_TOKEN: ${{ secrets.GITCODE_TOKEN }}
|
|
GITHUB_REPO: ${{ github.repository }}
|
|
TARGET_TAG: ${{ github.event.release.tag_name || inputs.tag }}
|
|
run: |
|
|
set -euo pipefail
|
|
if [ -z "$GITCODE_TOKEN" ]; then
|
|
echo "GITCODE_TOKEN secret is not configured; skipping release sync."
|
|
exit 0
|
|
fi
|
|
if [ -n "$TARGET_TAG" ]; then
|
|
python3 scripts/sync-gitcode-release.py "$TARGET_TAG"
|
|
else
|
|
python3 scripts/sync-gitcode-release.py
|
|
fi
|