diff --git a/.github/workflows/deploy-branch.yml b/.github/workflows/deploy-branch.yml new file mode 100644 index 00000000..e29f84c2 --- /dev/null +++ b/.github/workflows/deploy-branch.yml @@ -0,0 +1,71 @@ +name: Build PR or branch + +on: + push: + branches: + - 'deploy/**' + +env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + IMAGE_BASE: europe-north1-docker.pkg.dev/${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}/aap/${{ github.event.repository.name }} + +jobs: + bygg: + permissions: + contents: write + id-token: write + runs-on: ubuntu-latest + outputs: + image: ${{ steps.kompiler-pr.outputs.image }} + steps: + - name: Print number of PR + run: echo The Title of your PR is ${{ github.event.pull_request.number }} + + - name: Sjekk ut kode + uses: actions/checkout@v4.1.1 + + + - name: Setter opp Java 17 + uses: actions/setup-java@v3.13.0 + with: + java-version: 17 + distribution: temurin + cache: maven + + - name: Setter tag-navn + run: echo "TAG=$(date +%Y.%m.%d.%H%M%S)-$(echo $GITHUB_SHA | cut -c1-7)" >> $GITHUB_ENV + + - name: Setter image-navn + run: echo "IMAGE=$(echo $IMAGE_BASE):$(echo $TAG)-PR${{ steps.kompiler-pr.outputs.image }}" >> $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: aap + + - name: Kompiler + id: kompiler-pr + run: | + echo "image=${{ env.IMAGE }}" >> $GITHUB_OUTPUT + ./mvnw --batch-mode --settings .github/.m2/settings.xml -DGAR_TOKEN=${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }} package jib:build + + deploy: + + name: Deploy til dev-gcp + needs: bygg + runs-on: ubuntu-latest + timeout-minutes: 30 + environment: dev-gcp:aap + env: + PRINT_PAYLOAD: true + APIKEY: ${{secrets.NAIS_DEPLOY_APIKEY}} + RESOURCE: .nais/naiserator.yaml,.nais/dev-gcp-alerts.yaml + CLUSTER: dev-gcp + VARS: .nais/$dev-gcp.json + IMAGE: ${{needs.bygg.outputs.image}} + steps: + - uses: actions/checkout@v4.1.1 + - uses: nais/deploy/actions/deploy@master +