name: Mirror

on:
  push:
    branches: [main, "gitmsg/**"]
  workflow_run:
    workflows: [Release]
    types: [completed]
  workflow_dispatch:

jobs:
  gitlab:
    if: ${{ github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' }}
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
          lfs: true

      - run: scripts/mirror.sh gitlab "https://oauth2:${{ secrets.GITLAB_PAT }}@gitlab.com/gitsocial-org/gitsocial.git"

  codeberg:
    if: ${{ github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' }}
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
          lfs: true

      - run: scripts/mirror.sh codeberg "https://${{ secrets.CODEBERG_PAT }}@codeberg.org/GitSocial/gitsocial.git"
