Commit 699d7604 authored by Jorge Echevarria Uribarri's avatar Jorge Echevarria Uribarri Committed by GitHub
Browse files

Update gitlab.yml

parent 0b582c4d
Loading
Loading
Loading
Loading
+21 −18
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@ on:
      - develop  # Se activa cuando hay cambios en la rama develop

jobs:
  sync:
  create-merge-request:
    runs-on: ubuntu-latest

    steps:
@@ -14,23 +14,26 @@ jobs:
      - name: Checkout GitHub repository
        uses: actions/checkout@v4

      # 2. Configurar Git para empujar a GitLab
      - name: Push to GitLab main
      # 2. Crear un Merge Request en GitLab
      - name: Create Merge Request in GitLab
        env:
          GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }}
        run: |
          # Configurar Git
          git config --global user.name "github-actions[bot]"
          git config --global user.email "github-actions[bot]@users.noreply.github.com"

          # Agregar el repositorio remoto de GitLab
          git remote add gitlab https://oauth2:${GITLAB_TOKEN}@labs.etsi.org/rep/ocf/sdk.git

          # Traer la última versión de main desde GitLab
          git fetch gitlab main

          # Fusionar los cambios de main en develop (si es necesario)
          git merge gitlab/main

          # Empujar los cambios de develop a main en GitLab
          git push -u gitlab develop:main
          # Información del MR
          PROJECT_ID="335" # Reemplaza con el ID del proyecto de GitLab
          SOURCE_BRANCH="develop"
          TARGET_BRANCH="main"

          # Crear el Merge Request usando la API de GitLab
          curl -X POST \
            -H "Content-Type: application/json" \
            -H "Authorization: Bearer $GITLAB_TOKEN" \
            -d '{
              "id": "'"${PROJECT_ID}"'",
              "source_branch": "'"${SOURCE_BRANCH}"'",
              "target_branch": "'"${TARGET_BRANCH}"'",
              "title": "Sync develop to main",
              "remove_source_branch": false,
              "squash": false
            }' \
            https://labs.etsi.org/api/v4/projects/${PROJECT_ID}/merge_requests