Skip to content

Merge pull request #698 from navikt/FjernerRegel4og6 #933

Merge pull request #698 from navikt/FjernerRegel4og6

Merge pull request #698 from navikt/FjernerRegel4og6 #933

Workflow file for this run

name: build
on:
push:
branches:
- master
env:
IMAGE: ghcr.io/${{ github.repository }}:${{ github.sha }}
jobs:
build:
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- name: Checkout
uses: actions/checkout@master
- name: Cache
uses: actions/cache@v4
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle.kts') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Set up JDK 20
uses: actions/[email protected]
with:
distribution: 'adopt'
java-version: '20'
check-latest: true
cache: 'gradle'
- name: Bygg med gradle
run: ./gradlew test shadowJar
env:
ORG_GRADLE_PROJECT_githubUser: x-access-token
ORG_GRADLE_PROJECT_githubPassword: ${{ secrets.GITHUB_TOKEN }}
- name: Build docker image
run: docker build -t $IMAGE .
- name: Login to Github package registry
run: docker login ghcr.io -u ${GITHUB_REPOSITORY} -p ${GITHUB_TOKEN}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Push docker image
run: docker push $IMAGE
- name: Post failures to Slack
if: failure()
run: |
curl -X POST --data-urlencode "payload={\"channel\": \"$CHANNEL\", \"text\": \"$MESSAGE\", \"icon_emoji\": \":ghost:\"}" $WEBHOOK_URL
env:
MESSAGE: "Bygg feilet"
CHANNEL: "#team-p3-medlemskap-notifications"
WEBHOOK_URL: ${{ secrets.WEBHOOK_URL }}
deploypreprod:
name: Deploy to Preprod
needs: build
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
name: Checkout code
- uses: nais/deploy/actions/deploy@master
env:
APIKEY: ${{ secrets.NAIS_DEPLOY_API_KEY }}
CLUSTER: dev-gcp
RESOURCE: deploy/preprod.yaml
- name: Post failures to Slack
if: failure()
run: |
curl -X POST --data-urlencode "payload={\"channel\": \"$CHANNEL\", \"text\": \"$MESSAGE\", \"icon_emoji\": \":ghost:\"}" $WEBHOOK_URL
env:
MESSAGE: "Deploy til preprod feilet"
CHANNEL: "#team-p3-medlemskap-notifications"
WEBHOOK_URL: ${{ secrets.WEBHOOK_URL }}
deployprod:
name: Deploy to Prod
needs: deploypreprod
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
name: Checkout code
- uses: nais/deploy/actions/deploy@master
env:
APIKEY: ${{ secrets.NAIS_DEPLOY_API_KEY }}
CLUSTER: prod-gcp
RESOURCE: deploy/prod.yaml
- name: Post failures to Slack
if: failure()
run: |
curl -X POST --data-urlencode "payload={\"channel\": \"$CHANNEL\", \"text\": \"$MESSAGE\", \"icon_emoji\": \":ghost:\"}" $WEBHOOK_URL
env:
MESSAGE: "Deploy til prod feilet"
CHANNEL: "#team-p3-medlemskap-notifications"
WEBHOOK_URL: ${{ secrets.WEBHOOK_URL }}