Skip to content

PROD: Build and deploy til ebms til PROD #2

PROD: Build and deploy til ebms til PROD

PROD: Build and deploy til ebms til PROD #2

name: "PROD: Build and deploy til ebms til PROD"
on:
workflow_dispatch:
branches:
- main
env:
"IMAGE_CPA_SYNC": "ghcr.io/${{ github.repository }}/cpa-sync:${{ github.sha }}"
"IMAGE_SEND_IN": "ghcr.io/${{ github.repository }}/ebms-send-in:${{ github.sha }}"
jobs:
build:
name: "build"
runs-on: "ubuntu-20.04"
permissions:
packages: write
repository-projects: write
contents: write
steps:
- uses: "actions/checkout@v4"
- uses: "actions/setup-java@v3"
with:
"java-version": "21"
"distribution": "temurin"
- name: Cache gradle wrapper
uses: actions/cache@v3
with:
path: ~/.gradle/wrapper
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
- name: Cache Gradle packages
uses: actions/cache@v3
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-cache-${{ hashFiles('build.gradle') }}
restore-keys: |
${{ runner.os }}-gradle-cache-
- name: "Build and tests"
run: ./gradlew test build
env:
ORG_GRADLE_PROJECT_githubUser: x-access-token
ORG_GRADLE_PROJECT_githubPassword: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Login to GitHub Packages Docker Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: "Build and push cpa-sync Docker image"
run: "docker build cpa-sync --pull --tag ${IMAGE_CPA_SYNC} -f Dockerfile && docker push ${IMAGE_CPA_SYNC}"
- name: "Build and push ebms-send-in Docker image"
run: "docker build ebms-send-in --pull --tag ${IMAGE_SEND_IN} -f Dockerfile && docker push ${IMAGE_SEND_IN}"
deploy-cpa-sync:
name: "Deploy cpa-sync to prod"
needs: "build"
runs-on: "ubuntu-20.04"
permissions:
contents: read
id-token: write
steps:
- uses: "actions/checkout@v4"
- name: "Deploy to PROD"
uses: "nais/deploy/actions/deploy@v2"
env:
CLUSTER: "prod-fss"
RESOURCE: ".nais/cpa-sync-prod.yaml"
IMAGE: ${{env.IMAGE_CPA_SYNC}}
deploy-ebms-send-in:
name: "Deploy ebms-send-in to prod"
needs: "build"
runs-on: "ubuntu-20.04"
permissions:
contents: read
id-token: write
steps:
- uses: "actions/checkout@v4"
- name: "Deploy to PROD"
uses: "nais/deploy/actions/deploy@v2"
env:
CLUSTER: "prod-fss"
RESOURCE: ".nais/ebms-send-in-prod.yaml"
IMAGE: ${{env.IMAGE_SEND_IN}}