Skip to content

Commit

Permalink
feat(#11): improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
jhagestedt authored Apr 29, 2021
1 parent 83cc7d6 commit f38338b
Show file tree
Hide file tree
Showing 14 changed files with 272 additions and 317 deletions.
90 changes: 54 additions & 36 deletions .github/workflows/ci-main.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,60 @@
name: CI Main Branch
name: ci-main
on:
push:
branches:
- main
- main
jobs:
build:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'adopt'
- uses: s4u/[email protected]
with:
githubServer: false
servers: |
[
{
"id": "dgc-github",
"username": "${{ secrets.GPR_USER }}",
"password": "${{ secrets.GPR_PAT }}"
},
{
"id": "ehd-github",
"username": "${{ secrets.GPR_USER }}",
"password": "${{ secrets.GPR_PAT }}"
}
]
- name: Build
run: mvn install
- name: Build for Docker Image
run: mvn clean install -P docker
- name: Log into registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
- name: Build Docker Image
run: docker build target/docker --file target/docker/Dockerfile --tag docker.pkg.github.com/${{ github.repository }}/backend:latest
- name: Push Docker Image
run: docker push docker.pkg.github.com/${{ github.repository }}/backend:latest
- uses: actions/setup-java@v2
with:
java-version: 11
distribution: adopt
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/cache@v2
with:
path: |
~/.m2/repository
key: ${{ runner.os }}-${{ hashFiles('**/pom.xml') }}
- name: version
run: >-
APP_SHA=$(git rev-parse --short ${GITHUB_SHA});
APP_REV=$(git rev-list --tags --max-count=1);
APP_TAG=$(git describe --tags ${APP_REV} 2> /dev/null || echo 0.0.0);
APP_VERSION=${APP_TAG}-${APP_SHA};
echo "APP_SHA=${APP_SHA}" >> ${GITHUB_ENV};
echo "APP_TAG=${APP_TAG}" >> ${GITHUB_ENV};
echo "APP_VERSION=${APP_VERSION}" >> ${GITHUB_ENV};
- name: mvn
run: >-
mvn versions:set
--batch-mode
--file ./pom.xml
--settings ./settings.xml
--define newVersion="${APP_VERSION}";
mvn clean verify
--batch-mode
--file ./pom.xml
--settings ./settings.xml
--define app.packages.username="${APP_PACKAGES_USERNAME}"
--define app.packages.password="${APP_PACKAGES_PASSWORD}";
env:
APP_PACKAGES_USERNAME: ${{ github.actor }}
APP_PACKAGES_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
- name: docker
run: >-
echo "${APP_PACKAGES_PASSWORD}" |
docker login "${APP_PACKAGES_URL}"
--username "${APP_PACKAGES_USERNAME}"
--password-stdin;
docker build .
--file ./Dockerfile
--tag "${APP_PACKAGES_URL}:${APP_VERSION}";
docker push "${APP_PACKAGES_URL}:${APP_VERSION}";
env:
APP_PACKAGES_URL: docker.pkg.github.com/${{ github.repository }}/container
APP_PACKAGES_USERNAME: ${{ github.actor }}
APP_PACKAGES_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
60 changes: 31 additions & 29 deletions .github/workflows/ci-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,37 @@ name: ci-pull-request
on:
pull_request:
types:
- opened
- synchronize
- reopened
- opened
- synchronize
- reopened
jobs:
build:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'adopt'
- uses: s4u/maven-settings-action@v2
with:
githubServer: false
servers: |
[
{
"id": "dgc-github",
"username": "${{ secrets.GPR_USER }}",
"password": "${{ secrets.GPR_PAT }}"
},
{
"id": "ehd-github",
"username": "${{ secrets.GPR_USER }}",
"password": "${{ secrets.GPR_PAT }}"
}
]
- name: Build package
run: mvn --batch-mode package
- uses: actions/setup-java@v2
with:
java-version: 11
distribution: adopt
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/cache@v2
with:
path: |
~/.m2/repository
key: ${{ runner.os }}-${{ hashFiles('**/pom.xml') }}
- name: mvn
run: >-
mvn clean package
--batch-mode
--file ./pom.xml
--settings ./settings.xml
--define app.packages.username="${APP_PACKAGES_USERNAME}"
--define app.packages.password="${APP_PACKAGES_PASSWORD}";
env:
APP_PACKAGES_USERNAME: ${{ github.actor }}
APP_PACKAGES_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
- name: docker
run: >-
docker build .
--file ./Dockerfile;
31 changes: 19 additions & 12 deletions .github/workflows/ci-release-notes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,24 @@ name: ci-release-notes
on:
release:
types:
- created
- created
jobs:
build:
runs-on: ubuntu-latest
release-notes:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: release notes
run: |
TAG=${GITHUB_REF/refs\/tags\/}
npx github-release-notes release --override --tags ${TAG}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GREN_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: version
run: >-
APP_SHA=$(git rev-parse --short ${GITHUB_SHA});
APP_TAG=${GITHUB_REF/refs\/tags\/}
APP_VERSION=${APP_TAG};
echo "APP_SHA=${APP_SHA}" >> ${GITHUB_ENV};
echo "APP_TAG=${APP_TAG}" >> ${GITHUB_ENV};
echo "APP_VERSION=${APP_VERSION}" >> ${GITHUB_ENV};
- name: release-notes
run: npx github-release-notes release --override --tags ${APP_TAG}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GREN_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
61 changes: 61 additions & 0 deletions .github/workflows/ci-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: ci-release
on:
release:
types:
- created
jobs:
release:
runs-on: ubuntu-20.04
steps:
- uses: actions/setup-java@v2
with:
java-version: 11
distribution: adopt
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/cache@v2
with:
path: |
~/.m2/repository
key: ${{ runner.os }}-${{ hashFiles('**/pom.xml') }}
- name: version
run: >-
APP_SHA=$(git rev-parse --short ${GITHUB_SHA});
APP_TAG=${GITHUB_REF/refs\/tags\/}
APP_VERSION=${APP_TAG};
echo "APP_SHA=${APP_SHA}" >> ${GITHUB_ENV};
echo "APP_TAG=${APP_TAG}" >> ${GITHUB_ENV};
echo "APP_VERSION=${APP_VERSION}" >> ${GITHUB_ENV};
- name: mvn
run: >-
mvn versions:set
--batch-mode
--file ./pom.xml
--settings ./settings.xml
--define newVersion="${APP_VERSION}";
mvn clean deploy
--batch-mode
--file ./pom.xml
--settings ./settings.xml
--define app.packages.username="${APP_PACKAGES_USERNAME}"
--define app.packages.password="${APP_PACKAGES_PASSWORD}";
env:
APP_PACKAGES_USERNAME: ${{ github.actor }}
APP_PACKAGES_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
- name: docker
run: >-
echo "${APP_PACKAGES_PASSWORD}" |
docker login "${APP_PACKAGES_URL}"
--username "${APP_PACKAGES_USERNAME}"
--password-stdin;
docker build .
--file ./Dockerfile
--tag "${APP_PACKAGES_URL}:latest"
--tag "${APP_PACKAGES_URL}:${APP_VERSION}";
docker push "${APP_PACKAGES_URL}:latest";
docker push "${APP_PACKAGES_URL}:${APP_VERSION}";
env:
APP_PACKAGES_URL: docker.pkg.github.com/${{ github.repository }}/container
APP_PACKAGES_USERNAME: ${{ github.actor }}
APP_PACKAGES_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
45 changes: 0 additions & 45 deletions .github/workflows/ci-sonar-check.yml

This file was deleted.

39 changes: 39 additions & 0 deletions .github/workflows/ci-sonar.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: ci-sonar
on:
push:
branches:
- main
pull_request:
types:
- opened
- synchronize
- reopened
jobs:
sonar:
runs-on: ubuntu-20.04
steps:
- uses: actions/setup-java@v2
with:
java-version: 11
distribution: adopt
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/cache@v2
with:
path: |
~/.m2/repository
key: ${{ runner.os }}-${{ hashFiles('**/pom.xml') }}
- name: mvn
run: >-
mvn verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
--batch-mode
--file ./pom.xml
--settings ./settings.xml
--define app.packages.username="${APP_PACKAGES_USERNAME}"
--define app.packages.password="${APP_PACKAGES_PASSWORD}";
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
APP_PACKAGES_USERNAME: ${{ github.actor }}
APP_PACKAGES_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM adoptopenjdk:11-jre-hotspot
COPY ./target/*.jar /app/app.jar
WORKDIR /app
ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar ./app.jar" ]
8 changes: 4 additions & 4 deletions src/main/docker/docker-compose.yml → docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,24 @@ services:
backend:
build: .
image: eu-digital-green-certificates/dgc-issuance-service
container_name: dgc-gateway-backend
container_name: dgc-issuance-service
volumes:
- ./certs:/ec/prod/app/san/dgc
ports:
- 8080:8080
environment:
- SERVER_PORT=8080
- SPRING_PROFILES_ACTIVE=mysql
- SPRING_DATASOURCE_URL=jdbc:mysql://dgc-issuance-service-mysql:3306/fg
- SPRING_DATASOURCE_URL=jdbc:mysql://dgc-issuance-service-mysql:3306/dgc
- SPRING_DATASOURCE_USERNAME=dgc_adm
- SPRING_DATASOURCE_PASSWORD=admin
- efgs_dbencryption_password=aaaaaaaaaaaaaaaa
depends_on:
- mysql
networks:
backend:
persistence:
restart: unless-stopped

networks:
persistence:
backend:
persistence:
Loading

0 comments on commit f38338b

Please sign in to comment.