OPHJOD-1207: Create project structure #5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build: | |
permissions: | |
checks: write | |
contents: read | |
pull-requests: read | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-java@v4 | |
with: | |
distribution: corretto | |
java-version: 21 | |
- uses: gradle/actions/setup-gradle@v3 | |
- name: Build with Gradle | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
run: ./gradlew --no-daemon clean build sonar cyclonedxBom | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: application | |
path: | | |
build/libs/jod-ohjaaja-*.jar | |
!build/libs/*-plain.jar | |
- uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: reports | |
path: build/reports/ | |
docs: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-java@v4 | |
with: | |
distribution: corretto | |
java-version: 21 | |
- uses: gradle/actions/setup-gradle@v3 | |
- name: Generate documentation | |
run: ./gradlew --no-daemon generateOpenApiDocs generateSchemaDocs | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: openapi | |
path: build/openapi/openapi.json | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: database-schema-diagrams | |
path: build/schemaspy/diagrams | |
package: | |
needs: build | |
permissions: | |
id-token: write | |
contents: read | |
runs-on: ubuntu-latest | |
outputs: | |
tag: ${{ steps.short-tag.outputs.tag }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
with: | |
name: application | |
path: build/libs | |
- uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
role-to-assume: ${{ secrets.JOD_UTIL_AWS_ROLE_ARN }} | |
aws-region: eu-west-1 | |
- uses: docker/setup-buildx-action@v3 | |
- uses: docker/setup-qemu-action@v3 | |
- uses: docker/metadata-action@v5 | |
id: docker-meta | |
with: | |
images: "${{ secrets.JOD_ECR }}/oph/jod-ohjaaja" | |
tags: | | |
type=sha | |
- name: Output short tag | |
id: short-tag | |
run: | | |
echo "Short tag: ${DOCKER_METADATA_OUTPUT_TAGS##*:}" | |
echo "tag=${DOCKER_METADATA_OUTPUT_TAGS##*:}" >> $GITHUB_OUTPUT | |
- name: Login to ECR | |
id: ecr-login | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ secrets.JOD_ECR }} | |
- name: Build and push image | |
uses: docker/build-push-action@v6 | |
id: docker-build | |
with: | |
pull: true | |
push: "${{ github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch' }}" | |
platforms: linux/arm64,linux/amd64 | |
tags: ${{ steps.docker-meta.outputs.tags }} | |
labels: ${{ steps.docker-meta.outputs.labels }} | |
file: docker/Dockerfile | |
context: . | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
# deploy-dev: | |
# if: github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch' | |
# needs: package | |
# uses: ./.github/workflows/deploy.yml | |
# permissions: | |
# id-token: write | |
# secrets: inherit | |
# with: | |
# environment: dev | |
# tag: ${{ needs.package.outputs.tag }} | |
# | |
# deploy-test: | |
# if: github.ref == 'refs/heads/main' | |
# needs: | |
# - package | |
# - deploy-dev | |
# uses: ./.github/workflows/deploy.yml | |
# permissions: | |
# id-token: write | |
# secrets: inherit | |
# with: | |
# environment: test | |
# tag: ${{ needs.package.outputs.tag }} |