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 Original line Diff line number Diff line
@@ -6,7 +6,7 @@ on:
      - develop  # Se activa cuando hay cambios en la rama develop
      - develop  # Se activa cuando hay cambios en la rama develop


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


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


      # 2. Configurar Git para empujar a GitLab
      # 2. Crear un Merge Request en GitLab
      - name: Push to GitLab main
      - name: Create Merge Request in GitLab
        env:
        env:
          GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }}
          GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }}
        run: |
        run: |
          # Configurar Git
          # Información del MR
          git config --global user.name "github-actions[bot]"
          PROJECT_ID="335" # Reemplaza con el ID del proyecto de GitLab
          git config --global user.email "github-actions[bot]@users.noreply.github.com"
          SOURCE_BRANCH="develop"

          TARGET_BRANCH="main"
          # Agregar el repositorio remoto de GitLab

          git remote add gitlab https://oauth2:${GITLAB_TOKEN}@labs.etsi.org/rep/ocf/sdk.git
          # Crear el Merge Request usando la API de GitLab

          curl -X POST \
          # Traer la última versión de main desde GitLab
            -H "Content-Type: application/json" \
          git fetch gitlab main
            -H "Authorization: Bearer $GITLAB_TOKEN" \

            -d '{
          # Fusionar los cambios de main en develop (si es necesario)
              "id": "'"${PROJECT_ID}"'",
          git merge gitlab/main
              "source_branch": "'"${SOURCE_BRANCH}"'",

              "target_branch": "'"${TARGET_BRANCH}"'",
          # Empujar los cambios de develop a main en GitLab
              "title": "Sync develop to main",
          git push -u gitlab develop:main
              "remove_source_branch": false,
              "squash": false
            }' \
            https://labs.etsi.org/api/v4/projects/${PROJECT_ID}/merge_requests