nxtgauge-backend-rust/.github/workflows/sync-to-forgejo.yml
2026-07-05 19:12:35 +05:30

51 lines
1.6 KiB
YAML

name: sync-to-forgejo
on:
push:
branches:
- main
- high-performance
workflow_dispatch:
permissions:
contents: read
concurrency:
group: sync-to-forgejo-${{ github.ref }}
cancel-in-progress: true
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Configure Git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Push to Forgejo
env:
FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
run: |
set -euo pipefail
git remote add forgejo "https://admin:${FORGEJO_TOKEN}@ci.nxtgauge.com/ashwin/${{ github.event.repository.name }}.git" 2>/dev/null || \
git remote set-url forgejo "https://admin:${FORGEJO_TOKEN}@ci.nxtgauge.com/ashwin/${{ github.event.repository.name }}.git"
git push forgejo "HEAD:${GITHUB_REF#refs/heads/}" --force
- name: Trigger Forgejo Actions
env:
FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
run: |
set -euo pipefail
# Trigger workflow dispatch via Forgejo API
BRANCH="${GITHUB_REF#refs/heads/}"
curl -s -X POST \
-H "Authorization: token ${FORGEJO_TOKEN}" \
-H "Content-Type: application/json" \
"https://ci.nxtgauge.com/api/v1/repos/ashwin/${{ github.event.repository.name }}/actions/workflows/dispatches" \
-d "{\"ref\":\"${BRANCH}\"}" || echo "Workflow trigger attempted"