Skip to content

Commit

Permalink
Bygg til GAR i stedet for ghcr (#315)
Browse files Browse the repository at this point in the history
* Bygg til GAR i stedet for ghcr

* Flytt kotlin til egen sourcedir

* Fjern TestApplication som ikke brukes/vedlikeholdes

* bump deploy action
  • Loading branch information
holymaloney authored Oct 14, 2024
1 parent f97aafd commit 06c5238
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 95 deletions.
50 changes: 27 additions & 23 deletions .github/workflows/deploy-feature-branch-gcp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,20 @@ run-name: Deploy feature branch ${{ github.ref_name }} by @${{ github.actor }}
on:
workflow_dispatch:

permissions:
contents: read
packages: write

env:
IMAGE_TAG: ${{ github.sha }}
IMAGE: ghcr.io/${{ github.repository }}/veilarbdialog
PRINT_PAYLOAD: true

concurrency:
group: deploy_feature_branch
cancel-in-progress: true

jobs:
veilarbdialog:
name: Veilarbdialog - Test, build, push, deploy
build:
name: Veilarbdialog - Test, build, push
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -31,22 +28,29 @@ jobs:
cache: 'maven'
- name: Veilarbdialog - Build maven artifacts
run: mvn -B package
- uses: docker/login-action@v2
name: Veilarbdialog - Docker login
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v3
name: Veilarbdialog - Push image
- name: Push docker image to GAR
uses: nais/docker-build-push@v0
id: docker-build-push
with:
context: .
push: true
tags: ${{ env.IMAGE }}:${{ env.IMAGE_TAG }}
- name: Veilarbdialog - Deploy application
uses: nais/deploy/actions/deploy@v1
team: dab
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }} # Provided as Organization Secret
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }} # Provided as Organization Variable
outputs:
image: ${{ steps.docker-build-push.outputs.image }}
telemetry: ${{ steps.docker-build-push.outputs.telemetry }}
deploy:
name: Veilarbdialog - deploy to dev
needs: build
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Veilarbdialog - Deploy application to dev
uses: nais/deploy/actions/deploy@v2
env:
APIKEY: ${{ secrets.DAB_NAIS_DEPLOY_APIKEY }}
CLUSTER: dev-gcp
RESOURCE: nais/nais-dev-gcp.yaml
VAR: version=${{ env.IMAGE_TAG }}
VAR: image=${{ needs.build.outputs.image }}
TELEMETRY: ${{ needs.build.outputs.telemetry }}
71 changes: 46 additions & 25 deletions .github/workflows/deploy-gcp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,7 @@ on:
branches:
- main

permissions:
contents: read
packages: write

env:
IMAGE_TAG: ${{ github.sha }}
IMAGE: ghcr.io/${{ github.repository }}/veilarbdialog
PRINT_PAYLOAD: true

concurrency:
Expand All @@ -33,18 +27,26 @@ jobs:
cache: 'maven'
- name: Build maven artifacts
run: mvn -B package
- uses: docker/login-action@v2
name: Docker login
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v3
name: Push image
- name: Slack Notification (test failure)
if: failure()
uses: rtCamp/action-slack-notify@v2
env:
SLACK_COLOR: danger
SLACK_USERNAME: Github Actions
SLACK_ICON: https://github.com/github.png?size=48
SLACK_TITLE: 'Veilarbdialog: bygg feilet under deploy til prod'
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_MESSAGE: 'Commit-message til feilende deploy: ${{ github.event.head_commit.message }}'
- name: Push docker image to GAR
uses: nais/docker-build-push@v0
id: docker-build-push
with:
context: .
push: true
tags: ${{ env.IMAGE }}:${{ env.IMAGE_TAG }}
team: dab
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }} # Provided as Organization Secret
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }} # Provided as Organization Variable
outputs:
image: ${{ steps.docker-build-push.outputs.image }}
telemetry: ${{ steps.docker-build-push.outputs.telemetry }}

deploy-to-dev:
name: Deploy to dev
Expand All @@ -54,24 +56,43 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Deploy application to dev
uses: nais/deploy/actions/deploy@v1
uses: nais/deploy/actions/deploy@v2
env:
APIKEY: ${{ secrets.DAB_NAIS_DEPLOY_APIKEY }}
CLUSTER: dev-gcp
RESOURCE: nais/nais-dev-gcp.yaml
VAR: version=${{ env.IMAGE_TAG }}

VAR: image=${{ needs.test-build-push.outputs.image }}
TELEMETRY: ${{ needs.test-build-push.outputs.telemetry }}
- name: Slack Notification (deploy failure)
if: failure()
uses: rtCamp/action-slack-notify@v2
env:
SLACK_COLOR: danger
SLACK_USERNAME: Github Actions
SLACK_ICON: https://github.com/github.png?size=48
SLACK_TITLE: 'Veilarbdialog: deploy til dev feilet - deploy til prod ble ikke kjørt!'
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_MESSAGE: 'Commit-message til feilende deploy: ${{ github.event.head_commit.message }}'
deploy-to-prod:
name: Deploy to prod
runs-on: ubuntu-latest
needs: [ deploy-to-dev ]
needs: [ test-build-push, deploy-to-dev ]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Deploy application to prod
uses: nais/deploy/actions/deploy@v1
uses: nais/deploy/actions/deploy@v2
env:
APIKEY: ${{ secrets.DAB_NAIS_DEPLOY_APIKEY }}
CLUSTER: prod-gcp
RESOURCE: nais/nais-prod-gcp.yaml
VAR: version=${{ env.IMAGE_TAG }}
VAR: image=${{ needs.test-build-push.outputs.image }}
TELEMETRY: ${{ needs.test-build-push.outputs.telemetry }}
- name: Slack Notification (deploy failure)
if: failure()
uses: rtCamp/action-slack-notify@v2
env:
SLACK_COLOR: danger
SLACK_USERNAME: Github Actions
SLACK_ICON: https://github.com/github.png?size=48
SLACK_TITLE: 'Veilarbdialog: deploy til prod feilet'
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_MESSAGE: 'Commit-message til feilende deploy: ${{ github.event.head_commit.message }}'
2 changes: 1 addition & 1 deletion nais/nais-dev-gcp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
labels:
team: dab
spec:
image: ghcr.io/navikt/veilarbdialog/veilarbdialog:{{version}}
image: {{image}}
ingresses:
- https://veilarbdialog.dev.nav.cloud.nais.io
- https://veilarbdialog.intern.dev.nav.no
Expand Down
2 changes: 1 addition & 1 deletion nais/nais-prod-gcp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
labels:
team: dab
spec:
image: ghcr.io/navikt/veilarbdialog/veilarbdialog:{{version}}
image: {{image}}
ingresses:
- https://veilarbdialog.intern.nav.no
port: 8080
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@
</goals>
<configuration>
<sourceDirs>
<sourceDir>${project.basedir}/src/main/java</sourceDir>
<sourceDir>${project.basedir}/src/main/kotlin</sourceDir>
</sourceDirs>
</configuration>
</execution>
Expand All @@ -400,7 +400,7 @@
</goals>
<configuration>
<sourceDirs>
<sourceDir>${project.basedir}/src/test/java</sourceDir>
<sourceDir>${project.basedir}/src/test/kotlin</sourceDir>
</sourceDirs>
</configuration>
</execution>
Expand Down
43 changes: 0 additions & 43 deletions src/test/java/no/nav/fo/veilarbdialog/TestApplication.java

This file was deleted.

0 comments on commit 06c5238

Please sign in to comment.