fix: usar GITLAB_MIRROR_USER no espelhamento para GitLab #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Espelha main do GitHub para GitLab a cada push. | |
| # | |
| # Segredos no GitHub (Settings → Secrets → Actions): | |
| # GITLAB_MIRROR_TOKEN — token ou senha do Deploy Token / Project Access Token | |
| # GITLAB_MIRROR_USER — opcional; padrao oauth2 (PAT pessoal) ou usuario do Deploy Token | |
| # | |
| # Recomendado (plano gratuito): Deploy Token no projeto GitLab | |
| # Settings → Repository → Deploy tokens → write_repository | |
| name: Mirror to GitLab | |
| on: | |
| push: | |
| branches: [main] | |
| workflow_dispatch: | |
| concurrency: | |
| group: mirror-gitlab | |
| cancel-in-progress: true | |
| jobs: | |
| mirror: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Push to GitLab | |
| env: | |
| GITLAB_MIRROR_USER: ${{ secrets.GITLAB_MIRROR_USER }} | |
| GITLAB_MIRROR_TOKEN: ${{ secrets.GITLAB_MIRROR_TOKEN }} | |
| run: | | |
| if [ -z "$GITLAB_MIRROR_TOKEN" ]; then | |
| echo "ERRO: defina GITLAB_MIRROR_TOKEN nos secrets do GitHub." | |
| exit 1 | |
| fi | |
| GITLAB_USER="${GITLAB_MIRROR_USER:-oauth2}" | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git push "https://${GITLAB_USER}:${GITLAB_MIRROR_TOKEN}@gitlab.com/mariahilmar-group/mgi-kpi-pipeline.git" "HEAD:refs/heads/main" |