From 91f61f8ab59b1e5bebba21a0fa81876b9e0c070e Mon Sep 17 00:00:00 2001 From: Sakib Rahman Date: Fri, 5 Sep 2025 10:36:39 -0400 Subject: [PATCH 1/3] Add action to trigger gitlab pipelines --- .github/workflows/mirror.yaml | 59 +++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 .github/workflows/mirror.yaml diff --git a/.github/workflows/mirror.yaml b/.github/workflows/mirror.yaml new file mode 100644 index 0000000..b1a4f94 --- /dev/null +++ b/.github/workflows/mirror.yaml @@ -0,0 +1,59 @@ +name: Mirror and Trigger EICweb + +on: + delete: + push: + workflow_dispatch: + +concurrency: + group: mirror-${{ github.event_name }} + cancel-in-progress: false + +jobs: + build: + name: Mirror and Trigger EICweb + runs-on: ubuntu-latest + permissions: + actions: write + contents: read + statuses: write + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Push to EICweb + uses: eic/gitlab-sync@master + with: + url: https://eicweb.phy.anl.gov/EIC/campaigns/datasets.git + token: ${{ secrets.GITLAB_TOKEN }} + username: ${{ secrets.GITLAB_USERNAME }} + ciskip: true + - name: Trigger EICweb + id: trigger_eicweb + uses: eic/trigger-gitlab-ci@v3 + if: ${{ github.event_name != 'delete' }} + with: + url: https://eicweb.phy.anl.gov + project_id: 491 + token: ${{ secrets.EICWEB_CAMPAIGNS_DATASETS_TRIGGER }} + ref_name: ${{ github.event.pull_request.head.ref || github.ref }} + variables: | + GITHUB_REPOSITORY=${{ github.repository }} + GITHUB_SHA=${{ github.event.pull_request.head.sha || github.sha }} + GITHUB_PR=${{ github.event.pull_request.number }} + PIPELINE_NAME=${{ github.repository }}: ${{ github.event.pull_request.title || github.ref_name }} + - name: Set pending EICweb status + if: ${{ github.event_name != 'delete' }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + DETECTOR_CONFIG: epic_craterlake + run: | + curl \ + --fail-with-body \ + -X POST \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer $GITHUB_TOKEN" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + -d '{"context": "eicweb/campaigns/datasets (nightly, '"$DETECTOR_CONFIG"')", "state": "pending", "description": "Waiting for response from the EICweb", "target_url": "${{ fromJson(steps.trigger_eicweb.outputs.json).web_url }}"}' \ + "https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.event.pull_request.head.sha || github.sha }}" \ No newline at end of file From 6cd8561f9479bc5bb121bc6b180f93b67d85f072 Mon Sep 17 00:00:00 2001 From: Sakib Rahman Date: Fri, 5 Sep 2025 13:11:45 -0400 Subject: [PATCH 2/3] Use v1 of gitlab sync action --- .github/workflows/mirror.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/mirror.yaml b/.github/workflows/mirror.yaml index b1a4f94..43924fa 100644 --- a/.github/workflows/mirror.yaml +++ b/.github/workflows/mirror.yaml @@ -23,7 +23,7 @@ jobs: with: fetch-depth: 0 - name: Push to EICweb - uses: eic/gitlab-sync@master + uses: eic/gitlab-sync@v1 with: url: https://eicweb.phy.anl.gov/EIC/campaigns/datasets.git token: ${{ secrets.GITLAB_TOKEN }} @@ -56,4 +56,5 @@ jobs: -H "Authorization: Bearer $GITHUB_TOKEN" \ -H "X-GitHub-Api-Version: 2022-11-28" \ -d '{"context": "eicweb/campaigns/datasets (nightly, '"$DETECTOR_CONFIG"')", "state": "pending", "description": "Waiting for response from the EICweb", "target_url": "${{ fromJson(steps.trigger_eicweb.outputs.json).web_url }}"}' \ - "https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.event.pull_request.head.sha || github.sha }}" \ No newline at end of file + + "https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.event.pull_request.head.sha || github.sha }}" From a3ace9001d84add456ee98d16052b5f8c536be56 Mon Sep 17 00:00:00 2001 From: Sakib Rahman Date: Fri, 5 Sep 2025 14:16:28 -0400 Subject: [PATCH 3/3] Use environment variables for better readability in status action --- .github/workflows/mirror.yaml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/mirror.yaml b/.github/workflows/mirror.yaml index 43924fa..bcae56c 100644 --- a/.github/workflows/mirror.yaml +++ b/.github/workflows/mirror.yaml @@ -48,13 +48,14 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} DETECTOR_CONFIG: epic_craterlake + COMMIT_SHA: ${{ github.event.pull_request.head.sha || github.sha }} + REPO: ${{ github.repository }} + PIPELINE_URL: ${{ fromJson(steps.trigger_eicweb.outputs.json).web_url }} run: | - curl \ - --fail-with-body \ + curl --fail-with-body \ -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer $GITHUB_TOKEN" \ -H "X-GitHub-Api-Version: 2022-11-28" \ - -d '{"context": "eicweb/campaigns/datasets (nightly, '"$DETECTOR_CONFIG"')", "state": "pending", "description": "Waiting for response from the EICweb", "target_url": "${{ fromJson(steps.trigger_eicweb.outputs.json).web_url }}"}' \ - - "https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.event.pull_request.head.sha || github.sha }}" + -d "{\"context\": \"eicweb/campaigns/datasets (nightly, $DETECTOR_CONFIG)\", \"state\": \"pending\", \"description\": \"Waiting for response from the EICweb\", \"target_url\": \"$PIPELINE_URL\"}" \ + "https://api.github.com/repos/$REPO/statuses/$COMMIT_SHA"