This repository has been archived by the owner on Sep 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
79 lines (66 loc) · 2.04 KB
/
node-ci.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
name: CI/CD
on:
workflow_dispatch: {}
push:
branches:
- main
- '[0-9]+.x'
paths:
- src/**
- package-lock.json
- template.yaml
- .github/workflows/node-ci.yml
permissions:
id-token: write
contents: write
pull-requests: write
issues: write
jobs:
build:
name: Build & Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Setup NodeJS
uses: actions/setup-node@v3
with:
node-version: '20'
cache: npm
- name: Install dependencies
run: npm ci
- name: Build project
run: npm run build
- name: Lint the code
run: npm run lint:json
- name: Run unit tests
run: npm run test:cov
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: eu-central-1
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/ServerlessAppManagementAccess
role-duration-seconds: 1800
- name: Validate template
run: sam validate
- name: Create new release
uses: cycjimmy/semantic-release-action@v3
with:
extra_plugins: |
@semantic-release/exec
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Retrieve package version
id: package-version
run: echo "version=$(jq -r '.version' package.json)" >> $GITHUB_OUTPUT
- name: Rewrite ESLint report for SonarCloud
run: sed -i "s+${GITHUB_WORKSPACE}+/github/workspace+g" eslint-report.json
- name: SonarCloud Scan
uses: SonarSource/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
args: >
-Dsonar.projectVersion=${{ steps.package-version.outputs.version }}