From 52cd7f5027dd3353f78399958fcc14af0966499a Mon Sep 17 00:00:00 2001 From: "Michal J. Sladek" Date: Wed, 13 Apr 2022 14:42:42 +0200 Subject: [PATCH] Introduserer en swagger-starter prosjekt. (#28) * Introduserer en swagger-starter prosjekt. * Fjerner settings.xml * Legger i dependency management. --- .github/.m2/settings.xml | 41 ---------------------------------- .github/workflows/build-pr.yml | 10 ++++++++- .github/workflows/build.yml | 9 +++++++- .github/workflows/release.yml | 11 +++++++-- .github/workflows/snyk.yml | 31 +++++++++++++++++++++++++ pom.xml | 11 ++++++++- swagger-starter/pom.xml | 33 +++++++++++++++++++++++++++ 7 files changed, 100 insertions(+), 46 deletions(-) delete mode 100644 .github/.m2/settings.xml create mode 100644 .github/workflows/snyk.yml create mode 100644 swagger-starter/pom.xml diff --git a/.github/.m2/settings.xml b/.github/.m2/settings.xml deleted file mode 100644 index 85567f0a..00000000 --- a/.github/.m2/settings.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - github - - - - - github - - - central - https://repo1.maven.org/maven2 - - true - - - true - - - - github - GitHub Apache Maven Packages - https://maven.pkg.github.com/navikt/fp-bom/ - - - - - - - - github - x-access-token - ${env.GITHUB_TOKEN} - - - diff --git a/.github/workflows/build-pr.yml b/.github/workflows/build-pr.yml index e1e13342..4ff416e6 100644 --- a/.github/workflows/build-pr.yml +++ b/.github/workflows/build-pr.yml @@ -13,9 +13,17 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + + - name: Setup maven + uses: whelk-io/maven-settings-xml-action@v20 + with: + repositories: '[{ "id": "github", "name": "github", "url": "https://maven.pkg.github.com/${{ github.repository }}", "releases": { "enabled": "true" }, "snapshots": { "enabled": "false" } }]' + servers: '[{ "id": "github", "username": "${{ github.actor }}", "password": "${{ secrets.READER_TOKEN }}" }]' + output_file: settings.xml + - name: Build run: | echo "Verifying" - mvn verify -e --batch-mode --settings .github/.m2/settings.xml + mvn verify -e -B -s settings.xml env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index aef784c9..8f8de64f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,10 +20,17 @@ jobs: with: fetch-depth: "0" + - name: Setup maven + uses: whelk-io/maven-settings-xml-action@v20 + with: + repositories: '[{ "id": "github", "name": "github", "url": "https://maven.pkg.github.com/${{ github.repository }}", "releases": { "enabled": "true" }, "snapshots": { "enabled": "false" } }]' + servers: '[{ "id": "github", "username": "${{ github.actor }}", "password": "${{ secrets.READER_TOKEN }}" }]' + output_file: settings.xml + - name: Bygg shell: bash run: | - mvn verify -e --batch-mode --settings .github/.m2/settings.xml -DtrimStackTrace=false + mvn verify -e -B -s settings.xml -DtrimStackTrace=false env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 536bc45c..4e2eb4cc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,10 +13,17 @@ jobs: with: ref: 'master' + - name: Setup maven + uses: whelk-io/maven-settings-xml-action@v20 + with: + repositories: '[{ "id": "github", "name": "github", "url": "https://maven.pkg.github.com/${{ github.repository }}", "releases": { "enabled": "true" }, "snapshots": { "enabled": "false" } }]' + servers: '[{ "id": "github", "username": "${{ github.actor }}", "password": "${{ secrets.READER_TOKEN }}" }]' + output_file: settings.xml + - name: Publish artifact env: NEW_VERSION: ${{ github.event.release.tag_name }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - mvn -B --settings .github/.m2/settings.xml versions:set -DnewVersion=${NEW_VERSION} - mvn -B --settings .github/.m2/settings.xml clean deploy + mvn -B -s settings.xml versions:set -DnewVersion=${NEW_VERSION} + mvn -B -s settings.xml clean deploy diff --git a/.github/workflows/snyk.yml b/.github/workflows/snyk.yml new file mode 100644 index 00000000..65b92e49 --- /dev/null +++ b/.github/workflows/snyk.yml @@ -0,0 +1,31 @@ +name: Snyk vulnerabilities scanning of dependencies +on: + schedule: + - cron: '0 0 * * 1' + workflow_dispatch: + +jobs: + snyk: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Setup maven + uses: whelk-io/maven-settings-xml-action@v20 + with: + repositories: '[{ "id": "github", "name": "github", "url": "https://maven.pkg.github.com/${{ github.repository }}", "releases": { "enabled": "true" }, "snapshots": { "enabled": "false" } }]' + servers: '[{ "id": "github", "username": "${{ github.actor }}", "password": "${{ secrets.READER_TOKEN }}" }]' + output_file: settings.xml + + - name: Run Snyk + uses: snyk/actions/maven@master + with: + command: monitor + args: | + --org=teamforeldrepenger + --all-projects + --configuration-attributes=usage:java-runtime + --remote-repo-url=https://github.com/${{ github.repository }}.git + -- -s settings.xml + env: + SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} diff --git a/pom.xml b/pom.xml index 6d164dc4..a2441606 100644 --- a/pom.xml +++ b/pom.xml @@ -61,8 +61,17 @@ 3.10.1 + + swagger-starter + + + + no.nav.foreldrepenger.felles + swagger-starter + ${project.version} + no.nav.foreldrepenger konfig @@ -384,7 +393,7 @@ ${logback.version} - + io.swagger.core.v3 swagger-jaxrs2 diff --git a/swagger-starter/pom.xml b/swagger-starter/pom.xml new file mode 100644 index 00000000..e953bb18 --- /dev/null +++ b/swagger-starter/pom.xml @@ -0,0 +1,33 @@ + + + 4.0.0 + + + no.nav.foreldrepenger.felles + fp-bom + 1.0.0-SNAPSHOT + + + swagger-starter + pom + Foreldrepenger :: Swagger starter oppsett + + Starter prosjekt som includerer alle nødvendige avhengigheter til swagger-core med jaxrs2 støtte og swagger-ui. + + + + + io.swagger.core.v3 + swagger-core + + + io.swagger.core.v3 + swagger-jaxrs2 + + + org.webjars + swagger-ui + + +