Merge pull request #20 from wanam/wanam-patch-1 #77
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and deploy MDL image | |
env: | |
SPRING_PROFILES_ACTIVE: integration-test | |
REPO: mdl-geo-enrichment | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
build: | |
runs-on: processor1-akka | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: s4u/[email protected] | |
with: | |
java-version: 17 | |
maven-version: 3.8.5 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: '16.x' | |
- name: Maven | |
run: mvn -version | |
# build source code | |
- name: Build | |
run: mvn install -B -DskipTests | |
# run unit and integration tests | |
- name: Install OSM to GeoJson module | |
run: npm install -g osmtogeojson # install osmtogeojson module | |
- name: Install GTFS to GeoJson module | |
run: npm install -g gtfs-to-geojson # install gtfs-to-geojson module | |
- name: Run Integration tests | |
run: mvn verify | |
- name: Packaging... | |
run: mvn clean package -B -Dspring.profiles.active=prod -DskipTests | |
# build and deploy docker image | |
- name: Connect to docker registry | |
uses: docker/login-action@v2 | |
with: | |
#registry: ghcr.io # GitHub's registry | |
username: ${{ secrets.CI_REGISTRY_USER }} | |
password: ${{ secrets.CI_REGISTRY_PASSWORD }} | |
logout: true | |
- name: Build docker image | |
run: docker build -t wanam/${{ env.REPO }}:latest . | |
- name: Push the image to docker registy | |
run: docker push wanam/${{ env.REPO }}:latest | |
- name: Stop the container of the old image if running | |
run: docker stop mdl-geo-enrichment || true | |
- name: Force remove the container if it is still running | |
run: docker rm -f mdl-geo-enrichment || true | |
- name: Run new docker image | |
run: docker run --name mdl-geo-enrichment --restart always -d -p 62080:80 -p 443:443 wanam/${{ env.REPO }} |