Skip to content

Commit

Permalink
Add automatic build of docker image to github packages
Browse files Browse the repository at this point in the history
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
  • Loading branch information
edevosc2c authored and Gaetanbrl committed Feb 28, 2024
1 parent cb296d6 commit 3dd55ad
Showing 1 changed file with 19 additions and 23 deletions.
42 changes: 19 additions & 23 deletions .github/workflows/mapstore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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 }}

0 comments on commit 3dd55ad

Please sign in to comment.