|
| 1 | +name: klass-api-dev-build-and-deploy.yml |
| 2 | +on: |
| 3 | + workflow_dispatch: |
| 4 | + inputs: |
| 5 | + app: |
| 6 | + description: "Specify a custom name for your app" |
| 7 | + required: true |
| 8 | + type: string |
| 9 | + ttl: |
| 10 | + description: "Select required time for app to live" |
| 11 | + required: true |
| 12 | + default: '1h' |
| 13 | + type: choice |
| 14 | + options: |
| 15 | + - 1h |
| 16 | + - 2h |
| 17 | + - 4h |
| 18 | + - 8h |
| 19 | + - 36h |
| 20 | +jobs: |
| 21 | + build: |
| 22 | + name: Build |
| 23 | + permissions: |
| 24 | + contents: "read" |
| 25 | + id-token: "write" |
| 26 | + packages: "read" |
| 27 | + runs-on: ubuntu-latest |
| 28 | + outputs: |
| 29 | + image: ${{ steps.docker-build-push.outputs.image }} |
| 30 | + telemetry: ${{ steps.docker-build-push.outputs.telemetry }} |
| 31 | + test-config-changed: ${{ steps.test-config-changed.outputs.changed != 'non-inputs' }} |
| 32 | + only-config-changed: ${{ steps.changed-files.outputs.changed == 'only-inputs'}} |
| 33 | + |
| 34 | + steps: |
| 35 | + - name: Checkout |
| 36 | + uses: actions/checkout@v4 |
| 37 | + with: |
| 38 | + fetch-depth: 0 |
| 39 | + - uses: actions/setup-java@v4 |
| 40 | + with: |
| 41 | + distribution: 'temurin' |
| 42 | + java-version: '17' |
| 43 | + cache: 'maven' |
| 44 | + |
| 45 | + - name: Check what changed |
| 46 | + id: changed-files |
| 47 | + uses: "nais/what-changed@main" |
| 48 | + with: |
| 49 | + files: .nais/**/klass-api-dev.yaml |
| 50 | + main-branch-name: 'main' |
| 51 | + - name: Check for test config changes |
| 52 | + id: test-config-changed |
| 53 | + uses: "nais/what-changed@main" |
| 54 | + with: |
| 55 | + files: .nais/test/klass-api-dev.yaml |
| 56 | + main-branch-name: 'main' |
| 57 | + |
| 58 | + - name: Build with Maven |
| 59 | + if: steps.changed-files.outputs.changed != 'only-inputs' |
| 60 | + run: mvn --batch-mode --update-snapshots install |
| 61 | + env: |
| 62 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 63 | + |
| 64 | + - name: Build and push |
| 65 | + if: steps.changed-files.outputs.changed != 'only-inputs' |
| 66 | + uses: nais/docker-build-push@v0 |
| 67 | + id: docker-build-push |
| 68 | + with: |
| 69 | + team: dapla-metadata |
| 70 | + image_suffix: api |
| 71 | + dockerfile: klass-api/Dockerfile |
| 72 | + docker_context: klass-api |
| 73 | + |
| 74 | + deploy-test: |
| 75 | + name: Deploy to test |
| 76 | + needs: build |
| 77 | + permissions: |
| 78 | + contents: "read" |
| 79 | + id-token: "write" |
| 80 | + packages: "read" |
| 81 | + runs-on: ubuntu-latest |
| 82 | + steps: |
| 83 | + - name: Checkout |
| 84 | + uses: actions/checkout@v4 |
| 85 | + |
| 86 | + - uses: nais/deploy/actions/deploy@v2 |
| 87 | + env: |
| 88 | + CLUSTER: test |
| 89 | + RESOURCE: .nais/test/klass-api-dev.yaml |
| 90 | + DEPLOY_SERVER: deploy.ssb.cloud.nais.io:443 |
| 91 | + WORKLOAD_IMAGE: ${{ needs.build.outputs.image }} |
| 92 | + VAR: app-name=${{ github.event.inputs.app }},time-to-live=${{ github.event.inputs.ttl }} |
| 93 | + TELEMETRY: ${{ needs.build.outputs.telemetry }} |
0 commit comments