Legg til flere tester #328
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: Build & deploy | |
on: [push] | |
env: | |
IMAGE: ghcr.io/${{ github.repository }}/rekrutteringsbistand-stilling-indekser:${{ github.sha }} | |
jobs: | |
test: | |
name: Run tests | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- uses: actions/cache@v3 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: Run tests | |
run: ./gradlew test --info | |
deploy-to-dev: | |
name: Deploy to dev | |
needs: test | |
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/bruk-service-url' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- uses: actions/cache@v3 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: Build jar with Gradle | |
run: ./gradlew shadowJar | |
- name: Build and publish Docker image | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
docker build --tag ${IMAGE} . | |
echo ${GITHUB_TOKEN} | docker login ghcr.io -u ${GITHUB_REPOSITORY} --password-stdin | |
docker push ${IMAGE} | |
- uses: nais/deploy/actions/deploy@v1 | |
env: | |
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }} | |
CLUSTER: dev-gcp | |
VAR: image=${{ env.IMAGE }} | |
RESOURCE: nais/nais.yaml | |
VARS: nais/nais-dev.json | |
deploy-to-prod: | |
name: Deploy to prod | |
needs: deploy-to-dev | |
if: github.ref == 'refs/heads/main' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: nais/deploy/actions/deploy@v1 | |
env: | |
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }} | |
CLUSTER: prod-gcp | |
VAR: image=${{ env.IMAGE }} | |
RESOURCE: nais/nais.yaml | |
VARS: nais/nais-prod.json | |
deploy-alerts: | |
name: Deploy alerts to prod | |
if: github.ref == 'refs/heads/main' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: nais/deploy/actions/deploy@v1 | |
env: | |
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }} | |
CLUSTER: prod-gcp | |
RESOURCE: nais/alerts.yaml |