Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bytt til "nais/docker-build-push"-action #259

Merged
merged 1 commit into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions .github/workflows/build-deploy-feature-branch-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,40 +12,41 @@ jobs:
build-and-push:
name: Build and push
runs-on: ubuntu-latest
outputs:
image: ${{ steps.docker-build-push.outputs.image }}
permissions:
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'temurin'
cache: 'maven'
- name: Build maven artifacts
run: mvn -B package -D skipTests
- name: Login to Docker
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@v4
uses: nais/docker-build-push@v0
id: docker-build-push
with:
context: .
push: true
tags: ${{ env.IMAGE }}:${{ env.IMAGE_TAG }}
team: pto
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}

deploy-dev:
name: Deploy application to dev
needs: build-and-push
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Deploy application
uses: nais/deploy/actions/deploy@v1
env:
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
CLUSTER: dev-fss
RESOURCE: .nais/application/application-config-dev.yaml
VAR: version=${{ env.IMAGE_TAG }}
VAR: image=${{ needs.build-and-push.outputs.image }}
35 changes: 22 additions & 13 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ name: Build, push and deploy
on: push
env:
IMAGE_TAG: ${{ github.sha }}
IMAGE: ghcr.io/${{ github.repository }}/veilarbfilter
PRINT_PAYLOAD: true
permissions:
packages: write
Expand All @@ -15,43 +14,49 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'temurin'
cache: 'maven'

- name: Run maven tests
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: mvn -B verify

build-and-push:
name: Build and push
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/main'
outputs:
image: ${{ steps.docker-build-push.outputs.image }}
permissions:
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'temurin'
cache: 'maven'

- name: Build maven artifacts
run: mvn -B package -D skipTests
- name: Login to Docker
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@v4
uses: nais/docker-build-push@v0
id: docker-build-push
with:
context: .
push: true
tags: ${{ env.IMAGE }}:${{ env.IMAGE_TAG }}
team: pto
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}

deploy-dev:
name: Deploy application to dev
if: github.ref == 'refs/heads/dev'
Expand All @@ -60,13 +65,15 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Deploy application
uses: nais/deploy/actions/deploy@v1
env:
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
CLUSTER: dev-fss
RESOURCE: .nais/application/application-config-dev.yaml
VAR: version=${{ env.IMAGE_TAG }}
VAR: image=${{ needs.build-and-push.outputs.image }}

deploy-prod:
name: Deploy application to prod
if: github.ref == 'refs/heads/main'
Expand All @@ -75,13 +82,15 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Deploy application
uses: nais/deploy/actions/deploy@v1
env:
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
CLUSTER: prod-fss
RESOURCE: .nais/application/application-config-prod.yaml
VAR: version=${{ env.IMAGE_TAG }}
VAR: image=${{ needs.build-and-push.outputs.image }}

release-prod:
name: Create prod release
needs: deploy-prod
Expand Down
2 changes: 1 addition & 1 deletion .nais/application/application-config-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
labels:
team: pto
spec:
image: ghcr.io/navikt/veilarbfilter/veilarbfilter:{{version}}
image: {{image}}
replicas:
min: 1
max: 1
Expand Down
2 changes: 1 addition & 1 deletion .nais/application/application-config-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
labels:
team: pto
spec:
image: ghcr.io/navikt/veilarbfilter/veilarbfilter:{{version}}
image: {{image}}
port: 8080
vault:
enabled: true
Expand Down