diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 71d4362..734933b 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -3,12 +3,11 @@ on: push: branches: - master + paths-ignore: + - README.md env: - IMAGE: docker.pkg.github.com/${{ github.repository }}/pdfgen:${{ github.sha }} - GITHUB_SHA: ${{ github.sha }} - DOCKERHUB_IMAGE: navikt/pdfgen - + IMAGE: ghcr.io/${{ github.repository }} jobs: build: name: Build and push docker image @@ -45,24 +44,13 @@ jobs: ORG_GRADLE_PROJECT_githubPassword: ${{ secrets.GITHUB_TOKEN }} run: | ./gradlew shadowJar -x test - echo "version=$(./gradlew -q printVersion)" >> $GITHUB_ENV + echo "VERSION=$(./gradlew -q printVersion)" >> $GITHUB_ENV - name: Build Docker images run: | - docker build --tag ${IMAGE} . + docker build --tag ${IMAGE}:${VERSION} - name: Push docker image to GitHub env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - docker login docker.pkg.github.com -u ${GITHUB_REPOSITORY} -p ${GITHUB_TOKEN} - docker push ${IMAGE} - - name: Push docker image to Dockerhub - env: - DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} - run: | - docker login -u martinsolheim -p ${DOCKERHUB_TOKEN} - docker tag ${IMAGE} ${DOCKERHUB_IMAGE}:latest - docker tag ${IMAGE} ${DOCKERHUB_IMAGE}:${GITHUB_SHA} - docker tag ${IMAGE} ${DOCKERHUB_IMAGE}:${version} - docker push ${DOCKERHUB_IMAGE}:latest - docker push ${DOCKERHUB_IMAGE}:${GITHUB_SHA} - docker push ${DOCKERHUB_IMAGE}:${version} + docker login ghcr.io -u ${GITHUB_REPOSITORY} -p ${GITHUB_TOKEN} + docker push ${IMAGE}:${VERSION} diff --git a/.github/workflows/devdeploy.yml b/.github/workflows/test.yml similarity index 77% rename from .github/workflows/devdeploy.yml rename to .github/workflows/test.yml index bcec4e3..3624bc5 100644 --- a/.github/workflows/devdeploy.yml +++ b/.github/workflows/test.yml @@ -4,8 +4,6 @@ on: branches: - '*' - '!master' -env: - IMAGE: docker.pkg.github.com/${{ github.repository }}/pdfgen:${{ github.sha }} jobs: build: @@ -37,9 +35,3 @@ jobs: ORG_GRADLE_PROJECT_githubPassword: ${{ secrets.GITHUB_TOKEN }} run: | ./gradlew test - - name: Build jar - env: - ORG_GRADLE_PROJECT_githubUser: x-access-token - ORG_GRADLE_PROJECT_githubPassword: ${{ secrets.GITHUB_TOKEN }} - run: | - ./gradlew shadowJar -x test diff --git a/CODEOWNERS b/CODEOWNERS index e58b72d..ea590a6 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -1,2 +1,2 @@ -* @navikt/integrasjon -* @navikt/digisyfo +# benevolent dictator until further notice? :) +* @chinatsu diff --git a/LICENSE b/LICENSE index 181f469..8c2d79b 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2020 NAV (Arbeids- og velferdsdirektoratet) - The Norwegian Labour and Welfare Administration +Copyright (c) 2022 NAV (Arbeids- og velferdsdirektoratet) - The Norwegian Labour and Welfare Administration Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index bb837f2..4615ea0 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ -# PdfGen +# pdfgen ![Build and publish](https://github.com/navikt/pdfgen/workflows/Build%20and%20publish/badge.svg) -Repository for PdfGen, an application written in Kotlin used to create PDFs +Repository for `pdfgen`, an application written in Kotlin used to create PDFs ## Technologies & Tools @@ -11,8 +11,40 @@ Repository for PdfGen, an application written in Kotlin used to create PDFs * Ktor * Spek * Handlebars +* VeraPDF-validation ## Getting started + +Most commonly, pdfgen is used as a base image alongside templates, fonts, additional resources, and potential test data to verify that valid PDFs get produced by the aforementioned templates. + +In your own repository, create a Dockerfile with the following contents + +```dockerfile +# Dockerfile +FROM ghcr.io/navikt/pdfgen/pdfgen:a155cdaac6fcfebe60f1a2b012c1943b5b8f7bc0 + +COPY templates /app/templates # handlebars templates +COPY fonts /app/fonts # fonts to be embedded +COPY resources /app/resources # additional resources +``` + +Set up the basic folder structure +```bash +mkdir {templates,fonts,resources,data} +``` + +Create subfolders in `templates` and `data` +```bash +mkdir {templates,data}/your_teamname # your_teamname can be anything, but it'll be a necessary part of the API later +``` + +* `templates/your_teamname/` should then be populated with your .hbs-templates. the names of these templates will also decide parts of the API paths +* `data/your_teamname/` should be populated with json files with names corresponding to a target .hbs-template, this can be used to test your PDFs during development of templates. + +[navikt/flex-sykepengesoknad-pdfgen](https://github.com/navikt/flex-sykepengesoknad-pdfgen) is a good example of how such a project can be set up. + +## Developing pdfgen + ### Build and run tests `./gradlew shadowJar` @@ -23,19 +55,10 @@ making this ideal for developing new templates for your application. The template and data directory structure both follow the `/