Skip to content

Commit

Permalink
ci: add docker publish
Browse files Browse the repository at this point in the history
  • Loading branch information
pl-buiquang committed Jul 1, 2024
1 parent 45a2bd1 commit dd86343
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 51 deletions.
55 changes: 54 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,19 @@ jobs:
run: >
./mvnw clean install
- name: Upload the artifact
if: github.ref == 'refs/heads/main'
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
with:
fetch-depth: 0
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
Expand All @@ -43,3 +46,53 @@ jobs:
-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 artifacts
uses: actions/download-artifact@v3
with:
name: query-executor
path: target

- name: Fetch pg dependency
run: |
POSTGRES_VERSION=$(mvn help:evaluate -Dexpression=postgres.version -q -DforceStdout)
mvn org.apache.maven.plugins:maven-dependency-plugin:3.1.1:get -Dartifact=org.postgresql:postgresql:$POSTGRES_VERSION
mvn org.apache.maven.plugins:maven-dependency-plugin:3.1.1:copy -Dartifact=org.postgresql:postgresql:$POSTGRES_VERSION -DoutputDirectory=./
- 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:
context: .
file: ./Dockerfile
push: true
tags: "aphpid/cohort360-queryexecutor:${{ env.VERSION }}"
49 changes: 0 additions & 49 deletions .github/workflows/publish.yml

This file was deleted.

2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM harbor.eds.aphp.fr/cohort360/openjdk:11
FROM eclipse-temurin:11

RUN useradd -m -s /bin/bash -u 185 spark
USER spark
Expand Down

0 comments on commit dd86343

Please sign in to comment.