From 4f463b7eba2748001f6916550ab0e16a1f00e0d3 Mon Sep 17 00:00:00 2001 From: Nick Vanpraet Date: Tue, 29 Oct 2024 19:49:42 +0100 Subject: [PATCH 1/6] Add concurrency limit for mirroring and update gitlab ci to work with new API changes for DXP --- .github/workflows/gitlab_mirroring.yml | 3 +++ .gitlab-ci.yml | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/gitlab_mirroring.yml b/.github/workflows/gitlab_mirroring.yml index d426f7ff..b6b05cc2 100644 --- a/.github/workflows/gitlab_mirroring.yml +++ b/.github/workflows/gitlab_mirroring.yml @@ -6,6 +6,9 @@ jobs: sync: name: Gitlab Mirroring runs-on: ubuntu-latest + concurrency: + group: globally-unique-mirroring + cancel-in-progress: false steps: - uses: actions/checkout@v2 with: diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index afa84465..5a465070 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -16,7 +16,7 @@ deploy_to_qa_1: - >- curl --url 'https://admin.platform.dropsolid.com/project/mauticorg/environment/qa1/action.build?_format=json' - --data '{"branch":"'"${CI_COMMIT_REF_NAME}"'"}' + --data '{"branch":"'"${CI_COMMIT_REF_NAME}"'", "plugin_id": "git_reference"}' --header 'Content-type:application/json' --header "Authorization:Bearer ${GITLAB_API_TOKEN}" only: @@ -37,7 +37,7 @@ deploy_to_qa_2: - >- curl --url 'https://admin.platform.dropsolid.com/project/mauticorg/environment/qa2/action.build?_format=json' - --data '{"branch":"'"${CI_COMMIT_REF_NAME}"'"}' + --data '{"branch":"'"${CI_COMMIT_REF_NAME}"'", "plugin_id": "git_reference"}' --header 'Content-type:application/json' --header "Authorization:Bearer ${GITLAB_API_TOKEN}" only: @@ -58,7 +58,7 @@ deploy_to_qa_3: - >- curl --url 'https://admin.platform.dropsolid.com/project/mauticorg/environment/qa3/action.build?_format=json' - --data '{"branch":"'"${CI_COMMIT_REF_NAME}"'"}' + --data '{"branch":"'"${CI_COMMIT_REF_NAME}"'", "plugin_id": "git_reference"}' --header 'Content-type:application/json' --header "Authorization:Bearer ${GITLAB_API_TOKEN}" only: @@ -79,7 +79,7 @@ deploy_to_qa_4: - >- curl --url 'https://admin.platform.dropsolid.com/project/mauticorg/environment/qa4/action.build?_format=json' - --data '{"branch":"'"${CI_COMMIT_REF_NAME}"'"}' + --data '{"branch":"'"${CI_COMMIT_REF_NAME}"'", "plugin_id": "git_reference"}' --header 'Content-type:application/json' --header "Authorization:Bearer ${GITLAB_API_TOKEN}" only: From 8b567246448fdc66d3c035549fea8f6cd72c01ee Mon Sep 17 00:00:00 2001 From: Nick Vanpraet Date: Tue, 29 Oct 2024 20:42:16 +0100 Subject: [PATCH 2/6] Try different mirroring library --- .github/workflows/gitlab_mirroring.yml | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/.github/workflows/gitlab_mirroring.yml b/.github/workflows/gitlab_mirroring.yml index b6b05cc2..06821843 100644 --- a/.github/workflows/gitlab_mirroring.yml +++ b/.github/workflows/gitlab_mirroring.yml @@ -4,17 +4,12 @@ on: [ push, create, delete ] jobs: sync: - name: Gitlab Mirroring runs-on: ubuntu-latest - concurrency: - group: globally-unique-mirroring - cancel-in-progress: false steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - uses: action-pack/gitlab-sync@v3 - with: - username: ${{ github.actor }} - url: https://gitlab.dropsolid.com/project/mauticorg.git - token: ${{ secrets.GITLAB_MIRRORING_TOKEN }} + - uses: actions/checkout@v1 + - name: Mirror + uses: xometry/gitlab-mirror-action + env: + GITLAB_REPOSITORY: "https://gitlab.dropsolid.com/project/mauticorg.git" + GITLAB_USERNAME: ${{ github.actor }} + GITLAB_PASSWORD: ${{ secrets.GITLAB_MIRRORING_TOKEN }} From 084035dc679cc78acb872fb4b3bdc6b459cbafc5 Mon Sep 17 00:00:00 2001 From: Nick Vanpraet Date: Wed, 30 Oct 2024 16:35:51 +0100 Subject: [PATCH 3/6] try mirroring ourselves --- .github/scripts/mirror.sh | 50 ++++++++++++++++++++++++++ .github/workflows/gitlab_mirroring.yml | 7 ++-- 2 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 .github/scripts/mirror.sh diff --git a/.github/scripts/mirror.sh b/.github/scripts/mirror.sh new file mode 100644 index 00000000..69c12626 --- /dev/null +++ b/.github/scripts/mirror.sh @@ -0,0 +1,50 @@ +#!/usr/bin/env bash + +set -euo pipefail + +echo "${GITHUB_EVENT_NAME}" + +function git-setup() { + printf -v url "https://%s:%s@%s" \ + "${GITLAB_USERNAME}" \ + "${GITLAB_TOKEN}" \ + "${GITLAB_REPOSITORY#https://}" + echo "git remote add mirror ${url}" + git remote add mirror ${url} + set -x +} + +if test "$GITHUB_EVENT_NAME" == "create"; then + # Do nothing. Every "create" event *also* publishes a *push* event, even tags/branches created from github UI. + # Duplicate events would race and sometimes cause spurious errors. + echo "Ignoring create event, because the push event will handle updates." +elif test "$GITHUB_EVENT_NAME" == "push"; then + git-setup + git push mirror ${GITHUB_REF}:${GITHUB_REF} --force --tags + git remote remove mirror +elif test "$GITHUB_EVENT_NAME" == "workflow_run"; then + git-setup + git push mirror ${GITHUB_REF}:${GITHUB_REF} --force --tags + git remote remove mirror +elif test "$GITHUB_EVENT_NAME" == "workflow_dispatch"; then + git-setup + git push mirror ${GITHUB_REF}:${GITHUB_REF} --force --tags + git remote remove mirror +elif test "$GITHUB_EVENT_NAME" == "delete"; then + if test "$DELETED_REF_TYPE" == "tag"; then + FULL_DELETED_REF="refs/tags/$DELETED_REF" + elif test "$DELETED_REF_TYPE" == "branch"; then + FULL_DELETED_REF="refs/heads/$DELETED_REF" + else + echo "Unexpected DELETED_REF_TYPE=$DELETED_REF_TYPE, expected 'branch' or 'tag'" + exit 1 + fi + git-setup + git push mirror :${FULL_DELETED_REF} + git remote remove mirror +else + echo "Got unexpected GITHUB_EVENT_NAME: ${GITHUB_EVENT_NAME}" + exit 1 +fi + +echo "Done" diff --git a/.github/workflows/gitlab_mirroring.yml b/.github/workflows/gitlab_mirroring.yml index 06821843..70ab6501 100644 --- a/.github/workflows/gitlab_mirroring.yml +++ b/.github/workflows/gitlab_mirroring.yml @@ -6,10 +6,11 @@ jobs: sync: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v4 - name: Mirror - uses: xometry/gitlab-mirror-action + run: ./scripts/mirroring.sh + shell: bash env: GITLAB_REPOSITORY: "https://gitlab.dropsolid.com/project/mauticorg.git" GITLAB_USERNAME: ${{ github.actor }} - GITLAB_PASSWORD: ${{ secrets.GITLAB_MIRRORING_TOKEN }} + GITLAB_TOKEN: ${{ secrets.GITLAB_MIRRORING_TOKEN }} From 8e30eb5b8a1377fef1f282504ff9856d7115ecff Mon Sep 17 00:00:00 2001 From: Nick Vanpraet Date: Wed, 30 Oct 2024 16:38:40 +0100 Subject: [PATCH 4/6] check where we are --- .github/workflows/gitlab_mirroring.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/gitlab_mirroring.yml b/.github/workflows/gitlab_mirroring.yml index 70ab6501..d5e52064 100644 --- a/.github/workflows/gitlab_mirroring.yml +++ b/.github/workflows/gitlab_mirroring.yml @@ -8,7 +8,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Mirror - run: ./scripts/mirroring.sh + run: ls -lah shell: bash env: GITLAB_REPOSITORY: "https://gitlab.dropsolid.com/project/mauticorg.git" From fa3c9bd9961f70c8ca2c120acd8c39687d2fcc58 Mon Sep 17 00:00:00 2001 From: Nick Vanpraet Date: Wed, 30 Oct 2024 16:40:21 +0100 Subject: [PATCH 5/6] fix path --- .github/scripts/mirror.sh | 0 .github/workflows/gitlab_mirroring.yml | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 .github/scripts/mirror.sh diff --git a/.github/scripts/mirror.sh b/.github/scripts/mirror.sh old mode 100644 new mode 100755 diff --git a/.github/workflows/gitlab_mirroring.yml b/.github/workflows/gitlab_mirroring.yml index d5e52064..718a47c7 100644 --- a/.github/workflows/gitlab_mirroring.yml +++ b/.github/workflows/gitlab_mirroring.yml @@ -8,7 +8,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Mirror - run: ls -lah + run: .github/scripts/mirror.sh shell: bash env: GITLAB_REPOSITORY: "https://gitlab.dropsolid.com/project/mauticorg.git" From 2732b15178b217f28f5f30fa0bd76f685b23535b Mon Sep 17 00:00:00 2001 From: Nick Vanpraet Date: Wed, 30 Oct 2024 16:41:43 +0100 Subject: [PATCH 6/6] use full checkout --- .github/workflows/gitlab_mirroring.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/gitlab_mirroring.yml b/.github/workflows/gitlab_mirroring.yml index 718a47c7..18990930 100644 --- a/.github/workflows/gitlab_mirroring.yml +++ b/.github/workflows/gitlab_mirroring.yml @@ -7,6 +7,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Mirror run: .github/scripts/mirror.sh shell: bash