Skip to content

Commit d26e8ae

Browse files
committed
Added GHA jobs to project.
1 parent af07c02 commit d26e8ae

File tree

2 files changed

+94
-0
lines changed

2 files changed

+94
-0
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Manual build and deploy to dev environment
2+
on:
3+
workflow_dispatch:
4+
5+
env:
6+
IMAGE: docker.pkg.github.com/${{ github.repository }}/kabal-smart-editor-api:${{ github.sha }}
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v2
14+
- name: Cache
15+
uses: actions/[email protected]
16+
with:
17+
path: ~/.gradle/caches
18+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle.kts') }}
19+
restore-keys: |
20+
${{ runner.os }}-gradle-
21+
- name: Install Java 17
22+
uses: actions/[email protected]
23+
with:
24+
java-version: 17
25+
distribution: temurin
26+
- name: test and build
27+
run: ./gradlew test bootJar
28+
env:
29+
ORG_GRADLE_PROJECT_githubUser: x-access-token
30+
ORG_GRADLE_PROJECT_githubPassword: ${{ secrets.GITHUB_TOKEN }}
31+
- name: Build docker image
32+
run: docker build -t $IMAGE .
33+
- name: Login to Github package registry
34+
run: docker login docker.pkg.github.com -u ${GITHUB_REPOSITORY} -p ${GITHUB_TOKEN}
35+
env:
36+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37+
- name: Push docker image
38+
run: docker push $IMAGE
39+
- name: Post failures to Slack
40+
if: failure()
41+
run: |
42+
curl -X POST --data-urlencode "payload={\"channel\": \"$CHANNEL\", \"text\": \"$MESSAGE\", \"icon_emoji\": \":ghost:\"}" $WEBHOOK_URL
43+
env:
44+
MESSAGE: "Bygg feilet"
45+
CHANNEL: "#klage-notifications"
46+
WEBHOOK_URL: ${{ secrets.WEBHOOK_URL }}
47+
deploytodev:
48+
name: Deploy to dev
49+
needs: build
50+
runs-on: ubuntu-latest
51+
steps:
52+
- uses: actions/checkout@v2
53+
name: Checkout code
54+
- uses: nais/deploy/actions/deploy@v1
55+
env:
56+
APIKEY: ${{ secrets.NAIS_DEPLOY_API_KEY }}
57+
CLUSTER: dev-gcp
58+
RESOURCE: deploy/nais.yaml
59+
VARS: deploy/dev.yaml
60+
- name: Post failures to Slack
61+
if: failure()
62+
run: |
63+
curl -X POST --data-urlencode "payload={\"channel\": \"$CHANNEL\", \"text\": \"$MESSAGE\", \"icon_emoji\": \":ghost:\"}" $WEBHOOK_URL
64+
env:
65+
MESSAGE: "Deploy til dev feilet"
66+
CHANNEL: "#klage-notifications"
67+
WEBHOOK_URL: ${{ secrets.WEBHOOK_URL }}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: PR build
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v1
10+
- uses: actions/[email protected]
11+
with:
12+
path: ~/.gradle/caches
13+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle.kts') }}
14+
restore-keys: |
15+
${{ runner.os }}-gradle-
16+
- name: Sett opp Java 17
17+
uses: actions/[email protected]
18+
with:
19+
java-version: 17
20+
distribution: temurin
21+
- name: test and build
22+
run: ./gradlew test build
23+
env:
24+
ORG_GRADLE_PROJECT_githubUser: x-access-token
25+
ORG_GRADLE_PROJECT_githubPassword: ${{ secrets.GITHUB_TOKEN }}
26+
- name: build docker image
27+
run: docker build . --pull

0 commit comments

Comments
 (0)