Skip to content

ci: add docker publish #22

ci: add docker publish

ci: add docker publish #22

Workflow file for this run

name: build
on:
push:
branches:
- "**"
jobs:
build:
runs-on: ubuntu-20.04
steps:
- name: Checkout github repo
uses: actions/checkout@v4
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Build with maven
run: >
./mvnw clean install
- name: Upload the artifact
if: github.ref == 'refs/heads/add_docker_publish'
uses: actions/upload-artifact@v2
with:
name: query-executor
path: target/cohort-requester*.jar
sonar:
runs-on: ubuntu-20.04
steps:
- name: Checkout github repo
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 17
- name: Run sonarcloud analysis
run: >
./mvnw verify sonar:sonar
-Dsonar.sources=src/main/scala
-Dsonar.tests=src/test/scala
-Dsonar.scala.coverage.reportPaths=target/scoverage.xml
-Dsonar.host.url=https://sonarcloud.io
-Dsonar.organization=aphp
-Dsonar.projectKey=aphp_Cohort360-QueryExecutor
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
publish:
if: github.ref == 'refs/heads/add_docker_publish'
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: '11'
- name: Extract version from pom.xml
id: extract_version
run: |
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: query-executor
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
file: ./Dockerfile
push: true
tags: "aphpid/cohort360-queryexecutor:${{ env.VERSION }}"