Skip to content

Commit f9330c1

Browse files
NOJIRA: Bygg pull requests pa GHA (navikt#1121)
* NOJIRA: Bygg pull requests pa GHA * FIX: Setter opp githoots som executable. * NOJIRA: GHA workflow - nais oppsett som støttes mangler. Co-authored-by: Jan-Olav Eide <[email protected]>
1 parent 90b61ac commit f9330c1

File tree

7 files changed

+141
-8
lines changed

7 files changed

+141
-8
lines changed

.githooks/commit-msg

100644100755
File mode changed.

.githooks/pre-commit

100644100755
File mode changed.

.github/workflows/build-and-deploy-master.yml

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ name: Build, push and deploy Fpsak-frontend
22

33
on:
44
push:
5+
paths-ignore:
6+
- '**.md'
7+
- '.gitignore'
8+
- 'CODEOWNERS'
59
branches:
610
- master
711
env:
@@ -17,24 +21,33 @@ jobs:
1721
build:
1822
runs-on: ubuntu-latest
1923
steps:
20-
2124
- name: Sjekk ut kode
2225
uses: actions/checkout@v2
2326
- run: git fetch --prune --unshallow
2427

2528
- name: Hent tag
26-
run: echo "::set-env name=TAG::$(git log -1 --pretty='%ad' --date=format:'%Y%m%d%H%M%S')-$(echo $GITHUB_SHA | cut -c1-7)"
27-
29+
run: echo "::set-env name=TAG::$(git log -1 --pretty='%ad' --date=format:'%Y.%m.%d.%H%M%S')-$(echo $GITHUB_SHA | cut -c1-7)"
2830
- name: Sette opp Node
2931
uses: actions/setup-node@v1
3032
with:
3133
node-version: 12.x
34+
35+
- name: Get yarn cache
36+
id: yarn-cache
37+
run: |
38+
echo "::set-output name=dir::$(yarn cache dir)"
39+
40+
- name: Cache node modules
41+
uses: actions/[email protected]
42+
with:
43+
path: ${{ steps.yarn-cache.outputs.dir }}
44+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
3245

3346
- name: Run yarn install
3447
run: yarn install --ignore-optional --no-progress --frozen-lockfile
3548

3649
- name: Run linting and tests
37-
run: yarn less:lint
50+
run: yarn test && yarn less:lint && yarn ts-check
3851

3952
- name: Build
4053
run: |
@@ -55,21 +68,35 @@ jobs:
5568
token: ${{ secrets.GITHUB_TOKEN }}
5669
title: Bygg av ${{ env.TAG }}
5770
body: |
58-
Kommenter med <b>/promote ${{ env.TAG }} cluster namespace</b>, hvor <b>cluster</b> er et gyldig clusternavn og <b>namespace</b> et eksisterende namespace i det clusteret.
71+
Kommenter med <b>/promote cluster namespace</b>, hvor <b>cluster</b> er et gyldig clusternavn og <b>namespace</b> et eksisterende namespace i det clusteret.
5972
<table>
6073
<tr><th>Cluster</th><th>Namespace</th></tr>
61-
<tr><td>dev-fss</td><td>t4,q1</td></tr>
74+
<tr><td>dev-fss</td><td>t4, q1</td></tr>
6275
<tr><td>prod-fss</td><td>default</td></tr>
6376
</table>
77+
6478
- name: Trigg deploy til dev-fss t4
6579
if: success()
6680
uses: actions/[email protected]
6781
with:
68-
github-token: ${{secrets.NOTIFICATION}}
82+
github-token: ${{secrets.GH_P_TOKEN}}
83+
script: |
84+
const issue = { owner: context.issue.owner,
85+
repo: context.issue.repo,
86+
issue_number: ${{ steps.createdeployissue.outputs.number }} }
87+
github.issues.createComment({...issue,
88+
title: 'Deploy av ${{ env.TAG }}',
89+
body: '/promote dev-fss t4'})
90+
91+
- name: Trigg deploy til dev-fss q1
92+
if: success()
93+
uses: actions/[email protected]
94+
with:
95+
github-token: ${{secrets.GH_P_TOKEN}}
6996
script: |
7097
const issue = { owner: context.issue.owner,
7198
repo: context.issue.repo,
7299
issue_number: ${{ steps.createdeployissue.outputs.number }} }
73100
github.issues.createComment({...issue,
74101
title: 'Deploy av ${{ env.TAG }}',
75-
body: '/promote ${{ env.TAG }} ${{ env.CLUSTER }} ${{ env.NAMESPACE }}'})
102+
body: '/promote dev-fss q1'})

.github/workflows/dispatch.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Slash command dispatch
2+
on:
3+
issue_comment:
4+
types: [created]
5+
jobs:
6+
dispatcher:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Slash command dispatch
10+
uses: peter-evans/slash-command-dispatch@v1
11+
with:
12+
reaction-token: ${{ secrets.GITHUB_TOKEN }}
13+
token: ${{ secrets.GH_P_TOKEN }}
14+
commands: promote
15+
issue-type: issue
16+
allow_edits: true
17+
reactions: false

.github/workflows/promote.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Promote
2+
on:
3+
repository_dispatch:
4+
types: [promote-command]
5+
env:
6+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7+
IMAGE_BASE: docker.pkg.github.com/${{ github.repository }}/fpsak-frontend
8+
9+
jobs:
10+
promote:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
15+
- name: Set variabler for image, namespace og cluster
16+
shell: bash
17+
run: |
18+
echo "::set-env name=TAG::$(echo ${{ github.event.client_payload.github.payload.issue.title }} | awk '{print $NF}' | awk -F- '{print $NF}')"
19+
echo "::set-env name=IMAGE::$IMAGE_BASE:$(echo ${{ github.event.client_payload.github.payload.issue.title }} | awk '{print $NF}')"
20+
echo "::set-env name=CLUSTER::${{ github.event.client_payload.slash_command.arg1 }}"
21+
echo "::set-env name=NAMESPACE::${{ github.event.client_payload.slash_command.arg2 }}"
22+
23+
- name: Sjekk ut kode
24+
uses: actions/checkout@v1
25+
with:
26+
ref: ${{ env.TAG }}
27+
28+
- name: Promoter til cluster og namespace
29+
uses: nais/deploy/actions/deploy@v1
30+
env:
31+
APIKEY: ${{ secrets.DEPLOY_KEY }}
32+
CLUSTER: ${{ env.CLUSTER }}
33+
RESOURCE: deploy/${{ env.CLUSTER }}-${{ env.NAMESPACE }}.yml
34+
35+
- name: Oppdater kommentar med deployment status ved feil
36+
if: failure()
37+
uses: actions/[email protected]
38+
with:
39+
github-token: ${{secrets.GITHUB_TOKEN}}
40+
script: |
41+
const issue = { owner: context.issue.owner,
42+
repo: context.issue.repo,
43+
issue_number: ${{ github.event.client_payload.github.payload.issue.number }} }
44+
github.issues.createComment({...issue,
45+
title: 'Deploy av ${{ env.TAG }}',
46+
body: 'promote til ${{ github.event.client_payload.slash_command.args }} feilet'})
47+
48+
- name: Oppdater kommentar med deployment status
49+
if: success()
50+
uses: actions/[email protected]
51+
with:
52+
github-token: ${{secrets.GITHUB_TOKEN}}
53+
script: |
54+
const issue = { owner: context.issue.owner,
55+
repo: context.issue.repo,
56+
issue_number: ${{ github.event.client_payload.github.payload.issue.number }} }
57+
github.issues.createComment({...issue,
58+
body: 'promote til ${{ github.event.client_payload.slash_command.args }} utført'})
59+
github.issues.addLabels({...issue, labels: ['deployment','${{ env.CLUSTER }}-${{ env.NAMESPACE }}']})
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Valider pull request
2+
on: [pull_request]
3+
jobs:
4+
valid-pull-request:
5+
name: Valider pull request
6+
runs-on: ubuntu-latest
7+
steps:
8+
- name: Hente kode
9+
uses: actions/checkout@v1
10+
- name: Sette opp Node
11+
uses: actions/setup-node@v1
12+
with:
13+
node-version: 12.x
14+
15+
- name: Get yarn cache
16+
id: yarn-cache
17+
run: echo "::set-output name=dir::$(yarn cache dir)"
18+
- name: Cache node modules
19+
uses: actions/[email protected]
20+
with:
21+
path: ${{ steps.yarn-cache.outputs.dir }}
22+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
23+
24+
- name: Installere dependencies
25+
run: yarn install --ignore-optional --no-progress --frozen-lockfile
26+
- name: Tester og linting
27+
run: yarn test && yarn less:lint && yarn ts-check
28+
29+
- name: Run test and coverage
30+
run: yarn test:coverage

lsp/conf/properties.json

Whitespace-only changes.

0 commit comments

Comments
 (0)