Skip to content

Deploy only to test prod version #749

Deploy only to test prod version

Deploy only to test prod version #749

Workflow file for this run

name: Deploy to dev
on:
pull_request:
types: [ ready_for_review, opened, synchronize ]
env:
GITHUB_USERNAME: x-access-token
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
build:
permissions:
contents: "read"
id-token: "write"
name: Build with maven and docker
if: github.event.pull_request.draft == false && github.actor != 'dependabot[bot]'
runs-on: ubuntu-latest
steps:
- run: |
echo ${{github.actor}}
echo ${{github.triggering_actor}}
- uses: actions/checkout@v4
- uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- run: mvn -Dmaven.test.skip=true -B -e --settings .github/.m2/maven-settings.xml clean install
- uses: nais/docker-build-push@v0
id: docker-push
with:
team: bidrag
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
outputs:
image: ${{ steps.docker-push.outputs.image }}
tag: ${{ steps.docker-push.outputs.tag }}
run-tests:
runs-on: ubuntu-latest
name: Run tests
needs: build
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- run: mvn -B -e --settings .github/.m2/maven-settings.xml clean install
deploy-main:
runs-on: ubuntu-latest
name: Deploy main
needs: build
steps:
- uses: actions/checkout@v4
with:
path: deploy
- name: Deploy main branch to dev-fss
uses: nais/deploy/actions/deploy@v1
env:
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
CLUSTER: dev-fss
RESOURCE: deploy/.nais/nais.yaml
VARS: deploy/.nais/main.yaml
IMAGE: ${{ needs.build.outputs.image }}
run_cucumber:
runs-on: self-hosted
name: Run cucumber integration tests
needs: deploy-main
env:
INGRESS_OPPGAVE: https://oppgave.dev.intern.nav.no
INGRESS_ARKIV: https://bidrag-dokument-arkiv.dev.intern.nav.no
INGRESS_CUCUMBER: https://bidrag-cucumber-onprem.dev.intern.nav.no
INGRESS_DOKARKIV: https://dokarkiv-q2.dev.intern.nav.no
steps:
- name: "@arkiv-swagger"
run: |
curl -X 'POST' '${{ env.INGRESS_CUCUMBER }}/bidrag-cucumber-onprem/run' -i \
-H 'accept: */*' \
-H 'Content-Type: application/json' \
-d '{
"tags":["@arkiv-swagger"],
"ingressesForApps":["${{ env.INGRESS_ARKIV }}@bidrag-dokument-arkiv"]
}' | tee .cucumber-result
cat .cucumber-result | grep HTTP/1.1 | grep -c 200 > /dev/null # fails if count is 0 (http status is not ok, aka http status code is not 200)
- name: "@bidrag-dokument-arkiv"
run: |
curl -X 'POST' '${{ env.INGRESS_CUCUMBER }}/bidrag-cucumber-onprem/run' -i \
-H 'accept: */*' \
-H 'Content-Type: application/json' \
-d '{
"tags":["@bidrag-dokument-arkiv"],
"noContextPathForApps":["dokarkiv-api", "oppgave-api"],
"ingressesForApps":[
"${{ env.INGRESS_ARKIV }}@bidrag-dokument-arkiv",
"${{ env.INGRESS_OPPGAVE }}@oppgave-api",
"${{ env.INGRESS_DOKARKIV }}@dokarkiv-api"]
}' | tee .cucumber-result
cat .cucumber-result | grep HTTP/1.1 | grep -c 200 > /dev/null # fails if count is 0 (http status is not ok, aka http status code is not 200)
- name: "@arkiv-saf"
run: |
curl -X 'POST' '${{ env.INGRESS_CUCUMBER }}/bidrag-cucumber-onprem/run' -i \
-H 'accept: */*' \
-H 'Content-Type: application/json' \
-d '{
"tags":["@arkiv-saf"],
"noContextPathForApps":["dokarkiv-api"],"ingressesForApps":[
"${{ env.INGRESS_ARKIV }}@bidrag-dokument-arkiv",
"${{ env.INGRESS_DOKARKIV }}@dokarkiv-api"
]
}' | tee .cucumber-result
cat .cucumber-result | grep HTTP/1.1 | grep -c 200 > /dev/null # fails if count is 0 (http status is not ok, aka http status code is not 200)
remove_files_from_workspace:
name: Remove files from workspace
runs-on: self-hosted
needs: run_cucumber
if: ${{ always() }}
steps:
- name: Remove files from workspace
run: |
cd $RUNNER_WORKSPACE
echo deleting files in $RUNNER_WORKSPACE
sudo rm -rf *