nais compliancd #1656
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: PR build | |
on: [ pull_request ] | |
env: | |
APP: medlemskap-oppslag | |
jobs: | |
build_and_push: | |
name: Build and publish Docker image for PR-branch | |
runs-on: ubuntu-latest | |
permissions: | |
contents: "read" | |
packages: write | |
id-token: "write" | |
env: | |
IMAGE: ghcr.io/${{ github.repository }}:${{ github.sha }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.sha }} | |
- name: Set up Java | |
uses: actions/[email protected] | |
with: | |
java-version: '20' | |
distribution: 'temurin' | |
check-latest: true | |
- name: Cache gradle dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ~/.gradle/caches | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle.kts') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: Build with Gradle | |
run: ./gradlew test shadowJar --info | |
env: | |
ORG_GRADLE_PROJECT_githubUser: x-access-token | |
ORG_GRADLE_PROJECT_githubPassword: ${{ secrets.GITHUB_TOKEN }} | |
- uses: nais/docker-build-push@v0 | |
id: docker-push | |
with: | |
team: medlemskap # required | |
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }} # required, but is defined as an organization variable | |
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }} # required, but is defined as an organization secret | |
outputs: | |
image: ${{ steps.docker-push.outputs.image }} | |
deploypreprod: | |
name: Deploy PR-branch to dev | |
needs: [build_and_push] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: nais/deploy/actions/deploy@v2 | |
env: | |
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }} | |
CLUSTER: dev-gcp | |
RESOURCE: deploy/preprod.yaml | |
IMAGE: ${{ needs.build_and_push.outputs.image }} | |
TELEMETRY: ${{ needs.build_and_push.outputs.telemetry }} | |
acceptance-tests: | |
name: Run acceptance tests | |
needs: deploypreprod | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
repository: navikt/medlemskap-oppslag-funksjonelle-tester | |
- id: get-sha | |
run: | | |
echo ::set-output name=sha::$( curl -u "u:${{secrets.GITHUB_TOKEN}}" https://api.github.com/repos/navikt/medlemskap-oppslag-funksjonelle-tester/git/origin/migrere_til_sky | jq .object.sha | tr -d '"' ) | |
- uses: nais/deploy/actions/deploy@v2 | |
name: Run tests | |
env: | |
APIKEY: ${{ secrets.NAIS_DEPLOY_API_KEY }} | |
IMAGE: ghcr.io/navikt/medlemskap-oppslag-funksjonelle-tester:ac43a192b82f86524dec5cd3eca8779eb738f52d | |
CLUSTER: dev-gcp | |
VAR: app=medlemskap-oppslag | |
RESOURCE: nais/tests.yml | |
timeout-minutes: 5 |