-
-
Notifications
You must be signed in to change notification settings - Fork 44
73 lines (59 loc) · 2.05 KB
/
main.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
name: 'main'
concurrency: main_environment
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
cicd:
runs-on: ubuntu-latest
env:
CI: true
steps:
- name: 'Checkout sources'
uses: actions/checkout@v4
- name: 'Setup NodeJS'
uses: actions/setup-node@v4
with:
node-version: '20.x'
- name: 'Install dependencies'
run: yarn install
- name: 'Build distribution'
run: yarn action:dist
- name: 'Run unit-tests'
run: yarn test
- name: 'Run code coverage'
run: yarn run coverage
- name: 'Upload code coverage report'
run: bash <(curl -s https://codecov.io/bash) -t ${{secrets.CODECOV_SECRET_TOKEN }}
- name: 'Build server dist'
run: yarn server:dist
- name: 'Build docker image'
run: docker build -t cib .
- name: 'Configure AWS credentials'
if: ${{ github.actor != 'dependabot[bot]' }}
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_DEFAULT_REGION }}
- name: 'Login to Amazon ECR'
if: ${{ github.actor != 'dependabot[bot]' }}
uses: aws-actions/amazon-ecr-login@v2
with:
mask-password: 'true'
- name: 'Tag image for PR and push to ECR'
if: ${{ github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' }}
run: |
docker tag cib ${{ secrets.AWS_ECR_ENDPOINT }}:pr-${GITHUB_SHA::8}
docker push ${{ secrets.AWS_ECR_ENDPOINT }}:pr-${GITHUB_SHA::8}
- name: 'Tag image for main and push to ECR'
if: ${{ github.event_name == 'push' && github.actor != 'dependabot[bot]' }}
run: |
docker tag cib ${{ secrets.AWS_ECR_ENDPOINT }}:main-${GITHUB_SHA::8}
docker tag cib ${{ secrets.AWS_ECR_ENDPOINT }}:main-latest
docker push ${{ secrets.AWS_ECR_ENDPOINT }}:main-${GITHUB_SHA::8}
docker push ${{ secrets.AWS_ECR_ENDPOINT }}:main-latest