-
Notifications
You must be signed in to change notification settings - Fork 11
111 lines (104 loc) · 4.39 KB
/
template-ts-build-project.yaml
File metadata and controls
111 lines (104 loc) · 4.39 KB
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
#
# This reusable workflow is used to build a TypeScript project, run tests using vitest, and perform SonarCloud analysis.
# It is designed to be called from other workflows.
#
#
# HOW TO USE:
#
# To call this reusable workflow, copy the code between === lines to a new workflow file,
# uncomment and adjust "uses" as needed (use the latest tag available).
# ======================================================================
#
# name: xxxxx
#
# on:
# pull_request:
# branches:
# # every PR targetting main branch
# - main
# types:
# # on labeled and unlabeled to validate labels,
# # on closed to create tag when PR is merged
# types: [labeled, unlabeled, closed]
#
# jobs:
# build-n-test:
# uses: OutSystems/rd.github-reusable-workflows/.github/workflows/ts-build-project@vVersionHash
# with:
# github-ref: ${{ github.ref }}
# run-vitest: true # or false, depending on whether you want to run Vitest tests
# run-sonarcloud: true # or false, depending on whether you want to run SonarCloud analysis
# secrets:
# OSUI_AZURE_CLIENT_ID: ${{ secrets.OSUI_AZURE_CLIENT_ID }}
# OSUI_AZURE_TENANT_ID: ${{ secrets.OSUI_AZURE_TENANT_ID }}
# OSUI_AZURE_SUBSCRIPTION_ID: ${{ secrets.OSUI_AZURE_SUBSCRIPTION_ID }}
#
# ======================================================================
#
name: Build TS project
description: 'Build, run Vitest tests, and SonarCloud in a TypeScript project.'
on:
workflow_call:
inputs:
github-ref:
description: 'GitHub reference to be used as base to create a new one to generate and be published.'
type: string
required: true
run-vitest:
description: 'Defines if Vitest tests should be run or not.'
type: boolean
required: false
default: false
run-sonarcloud:
description: 'Defines if SonarCloud analysis should be run or not.'
type: boolean
required: false
default: false
secrets:
OSUI_AZURE_CLIENT_ID:
description: 'Azure Client ID for authentication'
required: true
OSUI_AZURE_TENANT_ID:
description: 'Azure Tenant ID for authentication'
required: true
OSUI_AZURE_SUBSCRIPTION_ID:
description: 'Azure Subscription ID for authentication'
required: true
jobs:
build-n-test:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- name: 📥 Checkout main branch
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: ${{ inputs.github-ref }}
- name: 🔐 Azure login
#uses: OutSystems/rd.github-reusable-workflows/.github/actions/az-login@9d497d1c5bc6e355aa8f4663539e6b75c212f6b4 #v2.0.7
uses: ./.github/actions/az-login
with:
client-id: ${{ secrets.OSUI_AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.OSUI_AZURE_TENANT_ID }}
subscription-id: ${{ secrets.OSUI_AZURE_SUBSCRIPTION_ID }}
- name: 🔑 Get SonarCloud token
id: get-sonarcloud-token
if: ${{ inputs.run-sonarcloud == true }}
#uses: OutSystems/rd.github-reusable-workflows/.github/actions/az-keyvault-get@9d497d1c5bc6e355aa8f4663539e6b75c212f6b4 #v2.0.7
uses: ./.github/actions/az-keyvault-get
with:
key-name: o11odc-github-sonarcloud-token-prd
- name: 🕸️ Install dependencies
run: npm install
- name: 🏗️ Run build
run: npm run build
- name: 🧪 Run Vitest with Code Coverage
if: ${{ inputs.run-vitest == true }}
run: npm run test:coverage
- name: 📊 Run sonarcloud analysis
#uses: OutSystems/rd.github-reusable-workflows/.github/actions/run-sonarcloud@3df86e14f6ad0021256077f91c43eca3f73d3b57 #v2.0.6
uses: ./.github/actions/run-sonarcloud
if: ${{ inputs.run-sonarcloud == true }}
with:
sonarcloud-token: ${{ steps.get-sonarcloud-token.outputs.az-keyvault-value }}