forked from smocker-dev/smocker
-
Notifications
You must be signed in to change notification settings - Fork 0
167 lines (135 loc) · 4.46 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
name: CI
on:
push:
branches:
- master
tags:
- "*.*.*" # semver, will override latest
- "*-preview" # preview, won't override latest
pull_request:
branches:
- master
workflow_dispatch: # Allow manual trigger
permissions:
id-token: write # This is required for requesting the AWS JWT
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- id: nvm
run: echo ::set-output name=NVMRC::$(cat .nvmrc)
- uses: actions/setup-node@v3
with:
node-version: "${{ steps.nvm.outputs.NVMRC }}"
cache: yarn
- run: yarn install --frozen-lockfile
- name: Lint sources
run: |
make lint
yarn lint
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- id: nvm
run: echo ::set-output name=NVMRC::$(cat .nvmrc)
- uses: actions/setup-node@v3
with:
node-version: "${{ steps.nvm.outputs.NVMRC }}"
cache: yarn
- name: Setup Go environment
uses: actions/setup-go@v4
with:
go-version: "^1.21.1"
- run: yarn install --frozen-lockfile
- name: Execute tests
run: |
make test
make test-integration
yarn test
make coverage
- name: SonarCloud Scan
uses: sonarsource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- id: extract_ref
run: echo ::set-output name=GIT_REF::$(echo ${GITHUB_REF##*/})
- id: nvm
run: echo ::set-output name=NVMRC::$(cat .nvmrc)
- uses: actions/setup-node@v3
with:
node-version: "${{ steps.nvm.outputs.NVMRC }}"
cache: yarn
- name: Setup Go environment
uses: actions/setup-go@v4
with:
go-version: "^1.21.1"
- run: yarn install --frozen-lockfile
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: us-east-1 # ECR Public can only be logged into from the us-east-1 region
role-to-assume: arn:aws:iam::202662887508:role/ecr-smocker
role-session-name: githubActions
- name: Login to Amazon ECR
id: login-ecr-public
uses: aws-actions/amazon-ecr-login@v2
with:
registry-type: public
mask-password: "true"
- name: Build
env:
ECR_REGISTRY: ${{ steps.login-ecr-public.outputs.registry }}
ECR_REPOSITORY: qonto/smocker
IMAGE_TAG: ${{ github.ref_name }}
run: |
make VERSION=${{ steps.extract_ref.outputs.GIT_REF }} RELEASE=1 release
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
# make VERSION=${{ steps.extract_ref.outputs.GIT_REF }} build-docker
# make VERSION=${{ steps.extract_ref.outputs.GIT_REF }} start-docker
# - if: startsWith(github.ref, 'refs/tags/')
# uses: actions/upload-artifact@v3
# with:
# name: smocker-bin
# path: ./build/smocker.tar.gz
# deploy:
# needs: [lint, test, build]
# if: startsWith(github.ref, 'refs/tags/')
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - id: extract_ref
# run: echo ::set-output name=GIT_REF::$(echo ${GITHUB_REF##*/})
# - uses: actions/download-artifact@v3
# with:
# name: smocker-bin
# path: ./build
# - run: cd build && tar -xvf smocker.tar.gz
# - name: Docker login
# uses: docker/login-action@v3
# with:
# username: ${{ secrets.DOCKER_USERNAME }}
# password: ${{ secrets.DOCKER_PASSWORD }}
# - name: Set up QEMU
# uses: docker/setup-qemu-action@v3
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v3
# with:
# platforms: linux/amd64,linux/arm64
# - name: Deploy on Docker registry
# run: make VERSION=${{ steps.extract_ref.outputs.GIT_REF }} deploy-docker
# - name: Deploy on GitHub releases
# uses: softprops/action-gh-release@v1
# with:
# files: build/smocker.tar.gz
# env:
# GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}