La til paths filter i api-start-stopp workflow #9
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, push, and deploy | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- 'api-start-stopp-perioder/**' | |
- '.github/workflows/api-start-stopp.yml' | |
- 'gradle/**' | |
- 'settings.gradle.kts' | |
- 'gradle.properties' | |
- 'gradlew' | |
env: | |
IMAGE: europe-north1-docker.pkg.dev/${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}/paw/${{ github.event.repository.name }} | |
jobs: | |
build: | |
name: Build - API Start Stopp | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
id-token: write | |
outputs: | |
image: ${{ steps.docker-build-push.outputs.image }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-java@v4 | |
with: | |
java-version: 21 | |
distribution: temurin | |
cache: gradle | |
- name: Set version | |
run: echo "VERSION=$(date +'%y.%m.%d').${{ github.run_number }}-${{ github.run_attempt }}" >> $GITHUB_ENV | |
- name: Login GAR | |
uses: nais/login@v0 | |
with: | |
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }} | |
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }} | |
team: paw | |
- name: Build and push image with Gradle | |
id: docker-build-push | |
working-directory: ./ | |
run: | | |
echo "image=${{ env.IMAGE }}:${{ env.VERSION }}" >> $GITHUB_OUTPUT | |
echo -Pversion=${{ env.VERSION }} -Pimage=${{ env.IMAGE }} build test jib | |
./gradlew -Pversion=${{ env.VERSION }} -Pimage=${{ env.IMAGE }} build test jib | |
echo "DIGEST=$(cat api-start-stopp-perioder/build/jib-image.digest)" >> $GITHUB_ENV | |
env: | |
ORG_GRADLE_PROJECT_githubPassword: ${{ secrets.GITHUB_TOKEN }} | |
- name: Attest and sign | |
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 | |
permissions: | |
contents: read | |
id-token: write | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: nais/deploy/actions/deploy@v2 | |
env: | |
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }} | |
CLUSTER: dev-gcp | |
RESOURCE: api-start-stopp/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 | |
# permissions: | |
# contents: read | |
# id-token: write | |
# steps: | |
# - uses: actions/checkout@v4 | |
# - uses: nais/deploy/actions/deploy@v1 | |
# env: | |
# TEAM: paw | |
# APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }} | |
# CLUSTER: prod-gcp | |
# RESOURCE: api-start-stopp/nais/nais-dev.yaml | |
# VAR: image=${{ needs.build.outputs.image }},env=dev,ingressDomain=intern.nav.no |