From c6fa8a6328863c66131ff4d446528cc280fdf0a4 Mon Sep 17 00:00:00 2001 From: Jean-Marc Bourdaret Date: Fri, 11 Mar 2022 17:09:04 +0100 Subject: [PATCH 1/4] force CI to build and tag on branch name (#3501) --- .github/workflows/mapstore.yml | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/.github/workflows/mapstore.yml b/.github/workflows/mapstore.yml index aebdcdd9b..b71cf5324 100644 --- a/.github/workflows/mapstore.yml +++ b/.github/workflows/mapstore.yml @@ -75,18 +75,13 @@ jobs: name: mapstore.war path: scratch/mapstore-${{ github.sha }}.war - - name: Getting image tag - if: github.repository == 'georchestra/mapstore2-georchestra' - id: version - run: echo ::set-output name=VERSION::$(echo $GITHUB_REF | cut -d / -f 3) - - name: "Building docker image" if: github.repository == 'georchestra/mapstore2-georchestra' run: | - cp scratch/mapstore-${{ github.sha }}.war docker/MapStore-${{ steps.version.outputs.VERSION }}.war - docker build . -t georchestra/mapstore:${{ steps.version.outputs.VERSION }} - # mvn -B package dockerfile:build -Pdocker,log4j-logstash,sentry-log4j -DdockerImageName=georchestra/mapstore:${{ steps.version.outputs.VERSION }} -settings settings.xml - working-directory: ${{ github.workspace }} + cp scratch/mapstore-${{ github.sha }}.war docker/MapStore-${GITHUB_REF_NAME}.war + docker build . -t georchestra/mapstore:$GITHUB_REF_NAME + # mvn -B package dockerfile:build -Pdocker,log4j-logstash,sentry-log4j -DdockerImageName=georchestra/mapstore:$GITHUB_REF_NAME -settings settings.xml + - name: "Logging in docker.io" if: github.repository == 'georchestra/mapstore2-georchestra' && github.event_name == 'push' uses: azure/docker-login@v1 @@ -97,11 +92,10 @@ jobs: - name: "Pushing latest to docker.io" if: github.ref == 'refs/heads/master' && github.repository == 'georchestra/mapstore2-georchestra' && github.event_name == 'push' run: | - docker tag georchestra/mapstore:${{ steps.version.outputs.VERSION }} georchestra/mapstore:latest + docker tag georchestra/mapstore:$GITHUB_REF_NAME georchestra/mapstore:latest docker push georchestra/mapstore:latest - working-directory: ${{ github.workspace }} - - name: "Pushing tag to docker.io" - if: contains(github.ref, 'refs/tags/') && github.repository == 'georchestra/mapstore2-georchestra' && github.event_name == 'push' + - name: "Pushing release to docker.io" + if: startWith(github.ref_name, '20') && github.repository == 'georchestra/mapstore2-georchestra' && github.event_name == 'push' run: | - docker push georchestra/mapstore:${{ steps.version.outputs.VERSION }} + docker push georchestra/mapstore:$GITHUB_REF_NAME From 1a998747b8320ea98cfffbf3087a38b33cf73bae Mon Sep 17 00:00:00 2001 From: Jean-Marc Bourdaret Date: Fri, 11 Mar 2022 17:32:06 +0100 Subject: [PATCH 2/4] typo in startSWith --- .github/workflows/mapstore.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/mapstore.yml b/.github/workflows/mapstore.yml index b71cf5324..abc7cc7c0 100644 --- a/.github/workflows/mapstore.yml +++ b/.github/workflows/mapstore.yml @@ -96,6 +96,6 @@ jobs: docker push georchestra/mapstore:latest - name: "Pushing release to docker.io" - if: startWith(github.ref_name, '20') && github.repository == 'georchestra/mapstore2-georchestra' && github.event_name == 'push' + if: startsWith(github.ref_name, '20') && github.repository == 'georchestra/mapstore2-georchestra' && github.event_name == 'push' run: | docker push georchestra/mapstore:$GITHUB_REF_NAME From da624ee3a2a2f75e5e32336ba6d87571afc43af4 Mon Sep 17 00:00:00 2001 From: Jean-Marc Bourdaret Date: Tue, 15 Mar 2022 10:11:49 +0100 Subject: [PATCH 3/4] restrict docker image building to 'push', excludes PR --- .github/workflows/mapstore.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/mapstore.yml b/.github/workflows/mapstore.yml index abc7cc7c0..c10c02af5 100644 --- a/.github/workflows/mapstore.yml +++ b/.github/workflows/mapstore.yml @@ -76,7 +76,7 @@ jobs: path: scratch/mapstore-${{ github.sha }}.war - name: "Building docker image" - if: github.repository == 'georchestra/mapstore2-georchestra' + if: github.repository == 'georchestra/mapstore2-georchestra' && github.event_name == 'push' run: | cp scratch/mapstore-${{ github.sha }}.war docker/MapStore-${GITHUB_REF_NAME}.war docker build . -t georchestra/mapstore:$GITHUB_REF_NAME From 29d554ae5f68914e74d5bc4f9ba1d729af3a7a69 Mon Sep 17 00:00:00 2001 From: Jean-Marc Bourdaret Date: Wed, 16 Mar 2022 10:10:34 +0100 Subject: [PATCH 4/4] check branch name before pushing to docker.io --- .github/workflows/mapstore.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/mapstore.yml b/.github/workflows/mapstore.yml index c10c02af5..fcfc9191f 100644 --- a/.github/workflows/mapstore.yml +++ b/.github/workflows/mapstore.yml @@ -95,7 +95,14 @@ jobs: docker tag georchestra/mapstore:$GITHUB_REF_NAME georchestra/mapstore:latest docker push georchestra/mapstore:latest + - name: "Check if branch name matches 20YY.MM.XX release pattern" + id: check-branch + run: | + if [[ ${{ github.ref_name }} =~ ^20[0-9]{2}\.[0-9]{2}\..+$ ]]; then + echo "::set-output name=releasematch::true" + fi + - name: "Pushing release to docker.io" - if: startsWith(github.ref_name, '20') && github.repository == 'georchestra/mapstore2-georchestra' && github.event_name == 'push' + if: steps.check-branch.outputs.releasematch == 'true' && github.repository == 'georchestra/mapstore2-georchestra' && github.event_name == 'push' run: | docker push georchestra/mapstore:$GITHUB_REF_NAME