From 0e45ed370e3786e3e97e57afee33060efbc53d15 Mon Sep 17 00:00:00 2001
From: Wouter Deconinck <wdconinc@gmail.com>
Date: Sat, 6 Jan 2024 19:15:04 -0600
Subject: [PATCH] fix(ci): mirror on push; trigger also on workflow_dispatch
 (#7)

* fix(ci): mirror on push; trigger also on workflow_dispatch

* fix(ci): always login/logout local registry
---
 .github/workflows/mirror.yaml |  3 ++-
 .gitlab-ci.yml                | 14 ++++++--------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/.github/workflows/mirror.yaml b/.github/workflows/mirror.yaml
index 57b2e6cb9..a60b501ab 100644
--- a/.github/workflows/mirror.yaml
+++ b/.github/workflows/mirror.yaml
@@ -22,6 +22,7 @@ jobs:
       with:
         fetch-depth: 0
     - name: Push to EICweb
+      if: github.event_name == 'push'
       uses: eic/gitlab-sync@master
       with:
         url: https://eicweb.phy.anl.gov/containers/eic_container.git/
@@ -29,7 +30,7 @@ jobs:
         username: ${{ secrets.GITLAB_USERNAME }}
         ciskip: true
     - name: Trigger EICweb
-      if: github.event_name == 'pull_request'
+      if: github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch'
       uses: eic/trigger-gitlab-ci@v2
       with:
         url: https://eicweb.phy.anl.gov
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 89a11fc72..6b864a3d2 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -159,7 +159,9 @@ status:pending:
   services:
     - docker:dind
   before_script:
-    - # Login to registries
+    - # Login to local registry
+      echo ${CI_REGISTRY_PASSWORD} | docker login -u ${CI_REGISTRY_USER} --password-stdin ${CI_REGISTRY}
+    - # Login to remote registries
       if [[ -n "${EXPORT_TAG}" ]] ; then
         if [[ -n "${DH_REGISTRY}" ]] ; then
           echo ${DH_EICWEB_TOKEN} | docker login -u ${DH_REGISTRY_USER} --password-stdin ${DH_REGISTRY} ;
@@ -167,12 +169,11 @@ status:pending:
         if [[ -n "${GH_REGISTRY}" ]] ; then
           echo ${GITHUB_REGISTRY_TOKEN} | docker login -u ${GITHUB_REGISTRY_USER} --password-stdin ${GH_REGISTRY} ;
         fi ;
-        if [[ -n "${CI_REGISTRY}" ]] ; then
-          echo ${CI_REGISTRY_PASSWORD} | docker login -u ${CI_REGISTRY_USER} --password-stdin ${CI_REGISTRY} ;
-        fi ;
       fi
   after_script:
-    - # Logout from registries
+    - # Logout from local registry
+      docker logout ${CI_REGISTRY}
+    - # Logout from remote registries
       if [[ -n "${EXPORT_TAG}" ]] ; then
         if [[ -n "${DH_REGISTRY}" ]] ; then
           docker logout ${DH_REGISTRY} ;
@@ -180,9 +181,6 @@ status:pending:
         if [[ -n "${GH_REGISTRY}" ]] ; then
           docker logout ${GH_REGISTRY} ;
         fi ;
-        if [[ -n "${CI_REGISTRY}" ]] ; then
-          docker logout ${CI_REGISTRY} ;
-        fi ;
       fi
 
 ## base job settings for all docker build jobs
-- 
GitLab