From 4e3dcf9fba4225e752dec89a2500e5e8abfbc699 Mon Sep 17 00:00:00 2001 From: Felix Dittrich Date: Tue, 27 Apr 2021 19:05:18 +0200 Subject: [PATCH] Add CI --- .github/workflows/ci-main.yml | 42 ++++++++++++++++++++++++ .github/workflows/ci-pull-request.yml | 36 +++++++++++++++++++++ .github/workflows/ci-release-notes.yml | 18 +++++++++++ .github/workflows/ci-sonar-check.yml | 45 ++++++++++++++++++++++++++ 4 files changed, 141 insertions(+) create mode 100644 .github/workflows/ci-main.yml create mode 100644 .github/workflows/ci-pull-request.yml create mode 100644 .github/workflows/ci-release-notes.yml create mode 100644 .github/workflows/ci-sonar-check.yml diff --git a/.github/workflows/ci-main.yml b/.github/workflows/ci-main.yml new file mode 100644 index 0000000..d9f770b --- /dev/null +++ b/.github/workflows/ci-main.yml @@ -0,0 +1,42 @@ +name: CI Main Branch +on: + push: + branches: + - main +jobs: + build: + runs-on: ubuntu-latest + 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.4.0 + 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 diff --git a/.github/workflows/ci-pull-request.yml b/.github/workflows/ci-pull-request.yml new file mode 100644 index 0000000..9b887ef --- /dev/null +++ b/.github/workflows/ci-pull-request.yml @@ -0,0 +1,36 @@ +name: ci-pull-request +on: + pull_request: + types: + - opened + - synchronize + - reopened +jobs: + build: + runs-on: ubuntu-latest + 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 diff --git a/.github/workflows/ci-release-notes.yml b/.github/workflows/ci-release-notes.yml new file mode 100644 index 0000000..2c6aa5c --- /dev/null +++ b/.github/workflows/ci-release-notes.yml @@ -0,0 +1,18 @@ +name: ci-release-notes +on: + release: + types: + - created +jobs: + build: + runs-on: ubuntu-latest + 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 }} + diff --git a/.github/workflows/ci-sonar-check.yml b/.github/workflows/ci-sonar-check.yml new file mode 100644 index 0000000..49be839 --- /dev/null +++ b/.github/workflows/ci-sonar-check.yml @@ -0,0 +1,45 @@ +name: Sonar Cloud Check +on: + workflow_dispatch: + push: + branches: + - main + pull_request: + types: + - opened + - synchronize + - reopened +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout Git + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Setup Java + 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: Sonar Check + run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file