-
Notifications
You must be signed in to change notification settings - Fork 108
81 lines (67 loc) · 1.97 KB
/
ci-build.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
name: CI Build App
on:
push:
branches: [master]
paths:
- 'src/**'
- '.github/workflows/**'
pull_request:
env:
IMAGE_REG: ghcr.io
IMAGE_REPO: benc-uk/nodejs-demoapp
permissions:
packages: write
statuses: write
checks: write
jobs:
test:
name: 'Tests & Linting'
runs-on: ubuntu-latest
steps:
- name: 'Checkout'
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20.x'
- name: 'Run linting'
run: make lint
- name: 'Run service'
run: make run &
- name: 'Run tests'
run: |
sleep 5
make test-report
- name: 'Test reporting'
uses: phoenix-actions/test-reporting@v8
id: test-report
if: success() || failure()
with:
name: Integration Test Report
path: test-results.xml
reporter: java-junit
fail-on-error: false
build:
name: 'Build & push image'
needs: test
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
steps:
- name: 'Checkout'
uses: actions/checkout@v4
# Nicer than using github runid, I think, will be picked up automatically by make
- name: 'Create datestamp image tag'
run: echo "IMAGE_TAG=$(date +%d-%m-%Y.%H%M)" >> $GITHUB_ENV
- name: 'Docker build image'
run: make image
# Only when pushing to default branch (e.g. master or main), then push image to registry
- name: 'Push to container registry'
run: |
echo ${{ secrets.GITHUB_TOKEN }} | docker login $IMAGE_REG -u $GITHUB_ACTOR --password-stdin
make push
- name: 'Trigger AKS release pipeline'
if: github.ref == 'refs/heads/master'
uses: benc-uk/workflow-dispatch@v1
with:
workflow: 'CD Release - AKS'
token: ${{ secrets.GH_PAT }}
inputs: '{ "IMAGE_TAG": "${{ env.IMAGE_TAG }}" }'