diff --git a/.github/workflows/gitlab.yml b/.github/workflows/gitlab.yml index 9ffac42f405792b0ac1dc0d35c3d799a22a88c26..68ca39aae391a1674e131aa1ff194b36b3b16c42 100644 --- a/.github/workflows/gitlab.yml +++ b/.github/workflows/gitlab.yml @@ -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