-
Notifications
You must be signed in to change notification settings - Fork 0
95 lines (82 loc) · 2.64 KB
/
build.yml
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
82
83
84
85
86
87
88
89
90
91
92
93
94
name: Build
on:
- push
env:
AWS_REGION: eu-north-1
ECR_REGISTRY: 095341522062.dkr.ecr.eu-north-1.amazonaws.com
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
id-token: write
contents: read
jobs:
lint-shell:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: espoon-voltti/voltti-actions/shellcheck@v1
dockerize:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- name: oppivelvollisuus/frontend
path: frontend
test_target: "test"
- name: oppivelvollisuus/api-gateway
path: api-gateway
- name: oppivelvollisuus/service
path: service
steps:
- uses: actions/checkout@v3
- name: Build image
uses: espoon-voltti/voltti-actions/docker-build-push@master
id: build
with:
path: ${{ matrix.path }}
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
AWS_ROLE_TO_ASSUME: ${{ secrets.AWS_ROLE }}
AWS_REGION: ${{ env.AWS_REGION }}
registry: ${{ env.ECR_REGISTRY }}
name: ${{ matrix.name }}
build-args: |
build=${{ github.run_number }}
commit=${{ github.sha }}
- name: Run Unit tests
if: ${{ matrix.test_target != '' }}
uses: espoon-voltti/voltti-actions/docker-build-push@master
id: test
with:
push: false
path: ${{ matrix.path }}
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
AWS_ROLE_TO_ASSUME: ${{ secrets.AWS_ROLE }}
AWS_REGION: ${{ env.AWS_REGION }}
registry: ${{ env.ECR_REGISTRY }}
name: ${{ matrix.name }}
build-args: |
build=${{ github.run_number }}
commit=${{ github.sha }}
target: ${{ matrix.test_target }}
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: ${{ env.AWS_REGION }}
role-to-assume: ${{ secrets.AWS_ROLE }}
role-duration-seconds: 1200
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- run: |
export TAG="{{ github.event.pull_request.head.sha || github.sha }}"
cd compose
./test-compose pull
./test-compose run service-tests