Merge remote-tracking branch 'origin/java_versjon_oppgradering' into … #908
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 | |
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/[email protected] | |
with: | |
path: ~/.gradle/caches | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle.kts') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: test and build | |
uses: actions/[email protected] | |
with: | |
distribution: 'adopt' | |
java-version: '20' | |
check-latest: true | |
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 }} |