From 6092c3f86474585af2606c5fa564b6ba0a7ffc37 Mon Sep 17 00:00:00 2001 From: Emilien Devos <121870973+edevosc2c@users.noreply.github.com> Date: Wed, 7 Feb 2024 19:25:30 +0100 Subject: [PATCH] Add automatic build of docker image to github packages Dont publish war to georchestra artifactory fix correct way to match 2023.02.xx-custom branch fix location for registry push Forgot second registry name --- .github/workflows/mapstore.yml | 42 +++++++++++++++------------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/.github/workflows/mapstore.yml b/.github/workflows/mapstore.yml index 66d897418..b158fb22f 100644 --- a/.github/workflows/mapstore.yml +++ b/.github/workflows/mapstore.yml @@ -4,6 +4,9 @@ on: [push, pull_request] jobs: build: runs-on: ubuntu-20.04 + permissions: + contents: read + packages: write steps: - name: "checking out" uses: actions/checkout@v2 @@ -57,13 +60,6 @@ jobs: - name: "package with Maven" run: mvn -B clean install -Dmapstore2.version=${{ github.sha }} - - name: "deploy war in artifactory" - run: cd web && mvn -B deploy -Dmapstore2.version=${{ github.sha }} - continue-on-error: true - env: - ARTIFACTORY_TOKEN_REF: ${{ secrets.ARTIFACTORY_TOKEN }} - ARTIFACTORY_USERNAME_REF: ${{ secrets.ARTIFACTORY_USERNAME }} - - name: "debian package with Maven" run: mvn -B package deb:package -pl web -PdebianPackage @@ -86,32 +82,32 @@ jobs: path: scratch/mapstore-${{ github.sha }}.war - name: Getting image tag - if: github.repository == 'georchestra/mapstore2-georchestra' + if: github.repository == 'geo2france/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' + if: github.repository == 'geo2france/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 + docker build . -t ghcr.io/geo2france/mapstore2-georchestra/mapstore:${{ steps.version.outputs.VERSION }} working-directory: ${{ github.workspace }} - - name: "Logging in docker.io" - if: github.repository == 'georchestra/mapstore2-georchestra' && github.event_name == 'push' - uses: azure/docker-login@v1 + - name: Login to GitHub Container Registry + if: github.repository == 'geo2france/mapstore2-georchestra' && github.event_name == 'push' + uses: docker/login-action@v1 with: - username: '${{ secrets.DOCKER_HUB_USERNAME }}' - password: '${{ secrets.DOCKER_HUB_PASSWORD }}' + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - - name: "Pushing latest to docker.io" - if: github.ref == 'refs/heads/master' && github.repository == 'georchestra/mapstore2-georchestra' && github.event_name == 'push' + - name: "Pushing 2023.02.xx-custom to registry" + if: github.ref == 'refs/heads/2023.02.xx-custom' && github.repository == 'geo2france/mapstore2-georchestra' && github.event_name == 'push' run: | - docker tag georchestra/mapstore:${{ steps.version.outputs.VERSION }} georchestra/mapstore:latest - docker push georchestra/mapstore:latest + docker tag ghcr.io/geo2france/mapstore2-georchestra/mapstore:${{ steps.version.outputs.VERSION }} ghcr.io/geo2france/mapstore2-georchestra/mapstore:2023.02.xx-custom + docker push ghcr.io/geo2france/mapstore2-georchestra/mapstore:2023.02.xx-custom 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 tag to registry" + if: contains(github.ref, 'refs/tags/') && github.repository == 'geo2france/mapstore2-georchestra' && github.event_name == 'push' run: | - docker push georchestra/mapstore:${{ steps.version.outputs.VERSION }} + docker push ghcr.io/geo2france/mapstore2-georchestra/mapstore:${{ steps.version.outputs.VERSION }}