Skip to content

Commit

Permalink
feat(#12): improve ci
Browse files Browse the repository at this point in the history
  • Loading branch information
jhagestedt authored May 1, 2021
1 parent d1c4dc6 commit b955861
Show file tree
Hide file tree
Showing 22 changed files with 377 additions and 321 deletions.
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_style = space
indent_size = 2
insert_final_newline = true

[*.java]
indent_size = 4
32 changes: 0 additions & 32 deletions .github/workflows/ci-dependency-check.yml

This file was deleted.

85 changes: 54 additions & 31 deletions .github/workflows/ci-main.yml
Original file line number Diff line number Diff line change
@@ -1,37 +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 }}"
}
]
- name: Build
run: mvn --batch-mode install
- name: Build for Docker
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 }}/dgca-verifier-service: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 }}
57 changes: 32 additions & 25 deletions .github/workflows/ci-pull-request.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,38 @@
name: CI Pull Request
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/[email protected]
with:
githubServer: false
servers: |
[
{
"id": "dgc-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;
33 changes: 20 additions & 13 deletions .github/workflows/ci-release-notes.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
name: CI Release Notes
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 }}
69 changes: 69 additions & 0 deletions .github/workflows/ci-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
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 }}
- name: assets
run: >-
gh release upload ${APP_TAG}
--clobber
./target/openapi-${APP_TAG}.json
./target/generated-resources/licenses-${APP_TAG}.xml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40 changes: 0 additions & 40 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 }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,5 @@ build/

### MAC OS ###
.DS_STORE

.settings.xml
Loading

0 comments on commit b955861

Please sign in to comment.