Deploy application #722
Workflow file for this run
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: Deploy application | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
env: | |
PRINT_PAYLOAD: true | |
TZ: Europe/Oslo | |
jobs: | |
test-build-and-push: | |
permissions: | |
contents: "write" | |
id-token: "write" | |
security-events: "write" | |
name: Test, build and push | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
cache: 'maven' | |
- name: Build maven artifacts | |
run: mvn -B package | |
- name: Dependency submission (for dependabot) | |
uses: advanced-security/maven-dependency-submission-action@v3 | |
- name: docker-build-push | |
uses: nais/docker-build-push@v0 | |
id: docker-build-push | |
with: | |
team: amt | |
tag: ${{ github.sha }} | |
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }} | |
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }} | |
outputs: | |
image: ${{ steps.docker-build-push.outputs.image }} | |
deploy-dev: | |
name: Deploy application to dev | |
needs: test-build-and-push | |
runs-on: ubuntu-latest | |
permissions: | |
contents: "write" | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Deploy application | |
uses: nais/deploy/actions/deploy@master | |
env: | |
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }} | |
CLUSTER: dev-gcp | |
RESOURCE: .nais/nais-dev.yaml | |
VARS: .nais/vars-dev.yaml | |
VAR: image=${{ needs.test-build-and-push.outputs.image }} | |
- name: Create release | |
uses: softprops/action-gh-release@v1 | |
with: | |
name: Release to dev | |
tag_name: release/dev@${{ github.sha }} | |
prerelease: true | |
deploy-prod: | |
name: Deploy application to prod | |
needs: [ test-build-and-push, deploy-dev ] | |
runs-on: ubuntu-latest | |
permissions: | |
contents: "write" | |
if: github.ref == 'refs/heads/main' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Deploy application | |
uses: nais/deploy/actions/deploy@master | |
env: | |
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }} | |
CLUSTER: prod-gcp | |
RESOURCE: .nais/nais-prod.yaml | |
VARS: .nais/vars-prod.yaml | |
VAR: image=${{ needs.test-build-and-push.outputs.image }} | |
- name: Create release | |
uses: softprops/action-gh-release@v1 | |
with: | |
name: Release to prod | |
tag_name: release/prod@${{ github.sha }} | |
prerelease: false |