Skip to content

Commit

Permalink
Tweaket alle github workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
naviktthomas committed Aug 14, 2024
1 parent 0ed83a6 commit 5ef3fa7
Show file tree
Hide file tree
Showing 6 changed files with 198 additions and 100 deletions.
Original file line number Diff line number Diff line change
@@ -1,34 +1,44 @@
name: Api Start stopp

on:
push:
paths:
- 'apps/api-start-stopp-perioder/**'
- 'domain/**'
- 'lib/**'
- '.github/workflows/api-start-stopp.yml'
- 'gradle/**'
- 'settings.gradle.kts'
- 'gradle.properties'
- 'gradlew'
push:
branches:
- main
- dev/*
paths:
- 'apps/api-start-stopp-perioder/**'
- 'lib/**'
- 'domain/**'
- '.github/workflows/api-start-stopp.yaml'
- 'gradle/**'
- 'settings.gradle.kts'
- 'gradle.properties'
- 'gradlew'
- 'gradlew.bat'

env:
IMAGE: europe-north1-docker.pkg.dev/${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}/paw/paw-arbeidssokerregisteret-api-inngang
jobs:
build:
name: Build - API Start Stopp
runs-on: ubuntu-latest
name: Build
permissions:
contents: read
id-token: write
packages: write
runs-on: ubuntu-latest
outputs:
image: ${{ steps.docker-build-push.outputs.image }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
- name: Checkout
uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v4
with:
java-version: 21
distribution: temurin
cache: gradle
- name: Set module
run: echo "MODULE=api-start-stopp-perioder" >> $GITHUB_ENV
- name: Set version
run: echo "VERSION=$(date +'%y.%m.%d').${{ github.run_number }}-${{ github.run_attempt }}" >> $GITHUB_ENV
- name: Login GAR
Expand All @@ -42,40 +52,52 @@ jobs:
working-directory: ./
run: |
echo "image=${{ env.IMAGE }}:${{ env.VERSION }}" >> $GITHUB_OUTPUT
./gradlew -Pversion=${{ env.VERSION }} -Pimage=${{ env.IMAGE }} :apps:api-start-stopp-perioder:test :apps:api-start-stopp-perioder:jib
echo "DIGEST=$(cat apps/api-start-stopp-perioder/build/jib-image.digest)" >> $GITHUB_ENV
echo -Pversion=${{ env.VERSION }} -Pimage=${{ env.IMAGE }} :apps:${{ env.MODULE }}:build :apps:${{ env.MODULE }}:jib
./gradlew -Pversion=${{ env.VERSION }} -Pimage=${{ env.IMAGE }} :apps:${{ env.MODULE }}:build :apps:${{ env.MODULE }}:jib
echo "DIGEST=$(cat apps/${{ env.MODULE }}/build/jib-image.digest)" >> $GITHUB_ENV
env:
ORG_GRADLE_PROJECT_githubPassword: ${{ secrets.GITHUB_TOKEN }}
- name: Attest and sign
- name: Attest and sign image
uses: nais/[email protected]
with:
image_ref: ${{ env.IMAGE }}@${{ env.DIGEST }}

deploy-dev:
name: Deploy to dev-gcp - API Start Stopp
needs: build
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/dev')
name: Deploy to dev-gcp
needs:
- build
permissions:
contents: read
id-token: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: nais/deploy/actions/deploy@v2
- name: Checkout
uses: actions/checkout@v4
- name: Deploy to GCP
uses: nais/deploy/actions/deploy@v2
env:
CLUSTER: dev-gcp
RESOURCE: apps/api-start-stopp-perioder/nais/nais-dev.yaml
VAR: image=${{ needs.build.outputs.image }}

deploy-prod:
if: github.ref == 'refs/heads/main'
name: Deploy to prod-gcp - API Start Stopp
needs: [build, deploy-dev]
runs-on: ubuntu-latest
name: Deploy to prod-gcp
needs:
- build
- deploy-dev
permissions:
contents: read
id-token: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: nais/deploy/actions/deploy@v2
- name: Checkout
uses: actions/checkout@v4
- name: Deploy to GCP
uses: nais/deploy/actions/deploy@v2
env:
TEAM: paw
CLUSTER: prod-gcp
RESOURCE: apps/api-start-stopp-perioder/nais/nais-prod.yaml
VAR: image=${{ needs.build.outputs.image }}
48 changes: 33 additions & 15 deletions .github/workflows/hendelselogg-backup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ name: Hendelselogg-backup

on:
push:
branches:
- main
- dev/*
paths:
- 'apps/hendelselogg-backup/**'
- 'lib/**'
Expand All @@ -11,25 +14,31 @@ on:
- 'settings.gradle.kts'
- 'gradle.properties'
- 'gradlew'
- 'gradlew.bat'

env:
IMAGE: europe-north1-docker.pkg.dev/${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}/paw/paw-arbeidssoekerregisteret-hendelselogg-backup
jobs:
build:
name: Build and push Docker container
runs-on: ubuntu-latest
name: Build
permissions:
contents: read
id-token: write
packages: write
runs-on: ubuntu-latest
outputs:
image: ${{ steps.docker-build-push.outputs.image }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
- name: Checkout
uses: actions/checkout@v3
- name: Setup Java
uses: actions/setup-java@v3
with:
java-version: 21
distribution: temurin
cache: gradle
- name: Set module
run: echo "MODULE=hendelselogg-backup" >> $GITHUB_ENV
- name: Set version
run: echo "VERSION=$(date +'%y.%m.%d').${{ github.run_number }}-${{ github.run_attempt }}" >> $GITHUB_ENV
- name: Login GAR
Expand All @@ -43,25 +52,30 @@ jobs:
working-directory: ./
run: |
echo "image=${{ env.IMAGE }}:${{ env.VERSION }}" >> $GITHUB_OUTPUT
./gradlew -Pversion=${{ env.VERSION }} -Pimage=${{ env.IMAGE }} :apps:hendelselogg-backup:build :apps:hendelselogg-backup:jib
echo "DIGEST=$(cat apps/hendelselogg-backup/build/jib-image.digest)" >> $GITHUB_ENV
echo -Pversion=${{ env.VERSION }} -Pimage=${{ env.IMAGE }} :apps:${{ env.MODULE }}:build :apps:${{ env.MODULE }}:jib
./gradlew -Pversion=${{ env.VERSION }} -Pimage=${{ env.IMAGE }} :apps:${{ env.MODULE }}:build :apps:${{ env.MODULE }}:jib
echo "DIGEST=$(cat apps/${{ env.MODULE }}/build/jib-image.digest)" >> $GITHUB_ENV
env:
ORG_GRADLE_PROJECT_githubPassword: ${{ secrets.GITHUB_TOKEN }}
- name: Attest and sign
- name: Attest and sign image
uses: nais/[email protected]
with:
image_ref: ${{ env.IMAGE }}@${{ env.DIGEST }}

deploy-dev:
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/dev')
name: Deploy to dev-gcp
needs: build
runs-on: ubuntu-latest
needs:
- build
permissions:
contents: read
id-token: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: nais/deploy/actions/deploy@v2
- name: Checkout
uses: actions/checkout@v3
- name: Deploy to GCP
uses: nais/deploy/actions/deploy@v2
env:
CLUSTER: dev-gcp
RESOURCE: apps/hendelselogg-backup/nais/nais-dev.yaml
Expand All @@ -70,14 +84,18 @@ jobs:
deploy-prod:
if: github.ref == 'refs/heads/main'
name: Deploy to prod-gcp
needs: [build, deploy-dev]
runs-on: ubuntu-latest
needs:
- build
- deploy-dev
permissions:
contents: read
id-token: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: nais/deploy/actions/deploy@v2
- name: Checkout
uses: actions/checkout@v3
- name: Deploy to GCP
uses: nais/deploy/actions/deploy@v2
env:
TEAM: paw
CLUSTER: prod-gcp
Expand Down
51 changes: 35 additions & 16 deletions .github/workflows/hendelseprosessor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ name: Hendelseprosessor

on:
push:
branches:
- main
- dev/*
paths:
- 'apps/hendelseprosessor/**'
- 'lib/**'
Expand All @@ -11,25 +14,31 @@ on:
- 'settings.gradle.kts'
- 'gradle.properties'
- 'gradlew'
- 'gradlew.bat'

env:
IMAGE: europe-north1-docker.pkg.dev/${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}/paw/paw-arbeidssokerregisteret-event-prosessor
jobs:
build:
name: Build and push Docker container
runs-on: ubuntu-latest
name: Build
permissions:
contents: read
id-token: write
packages: write
runs-on: ubuntu-latest
outputs:
image: ${{ steps.docker-build-push.outputs.image }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
- name: Checkout
uses: actions/checkout@v3
- name: Setup Java
uses: actions/setup-java@v3
with:
java-version: 21
distribution: temurin
cache: gradle
- name: Set module
run: echo "MODULE=hendelseprosessor" >> $GITHUB_ENV
- name: Set version
run: echo "VERSION=$(date +'%y.%m.%d').${{ github.run_number }}-${{ github.run_attempt }}" >> $GITHUB_ENV
- name: Login GAR
Expand All @@ -43,24 +52,30 @@ jobs:
working-directory: ./
run: |
echo "image=${{ env.IMAGE }}:${{ env.VERSION }}" >> $GITHUB_OUTPUT
./gradlew -Pversion=${{ env.VERSION }} -Pimage=${{ env.IMAGE }} :apps:hendelseprosessor:build :apps:hendelseprosessor:jib
echo "DIGEST=$(cat apps/hendelseprosessor/build/jib-image.digest)" >> $GITHUB_ENV
echo -Pversion=${{ env.VERSION }} -Pimage=${{ env.IMAGE }} :apps:${{ env.MODULE }}:build :apps:${{ env.MODULE }}:jib
./gradlew -Pversion=${{ env.VERSION }} -Pimage=${{ env.IMAGE }} :apps:${{ env.MODULE }}:build :apps:${{ env.MODULE }}:jib
echo "DIGEST=$(cat apps/${{ env.MODULE }}/build/jib-image.digest)" >> $GITHUB_ENV
env:
ORG_GRADLE_PROJECT_githubPassword: ${{ secrets.GITHUB_TOKEN }}
- name: Attest and sign
- name: Attest and sign image
uses: nais/[email protected]
with:
image_ref: ${{ env.IMAGE }}@${{ env.DIGEST }}

deploy-dev:
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/dev')
name: Deploy to dev-gcp
needs: build
runs-on: ubuntu-latest
needs:
- build
permissions:
contents: read
id-token: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: nais/deploy/actions/deploy@v2
- name: Checkout
uses: actions/checkout@v3
- name: Deploy to GCP
uses: nais/deploy/actions/deploy@v2
env:
CLUSTER: dev-gcp
RESOURCE: apps/hendelseprosessor/nais/nais-dev.yaml
Expand All @@ -69,16 +84,20 @@ jobs:
deploy-prod:
if: github.ref == 'refs/heads/main'
name: Deploy to prod-gcp
needs: [build, deploy-dev]
runs-on: ubuntu-latest
needs:
- build
- deploy-dev
permissions:
contents: read
id-token: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: nais/deploy/actions/deploy@v2
- name: Checkout
uses: actions/checkout@v3
- name: Deploy to GCP
uses: nais/deploy/actions/deploy@v2
env:
TEAM: paw
CLUSTER: prod-gcp
RESOURCE: apps/hendelseprosessor/nais/nais-prod.yaml
VAR: image=${{ needs.build.outputs.image }},kafka=nav-prod
VAR: image=${{ needs.build.outputs.image }},kafka=nav-prod
Loading

0 comments on commit 5ef3fa7

Please sign in to comment.