-
Notifications
You must be signed in to change notification settings - Fork 0
94 lines (82 loc) · 3.27 KB
/
ci-cd.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: CI/CD
on:
push:
branches:
- main
paths-ignore:
- '**/version.json'
- '**/CHANGELOG.MD'
tags-ignore:
- 'v*'
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.event.number || github.ref }}
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') || startsWith(github.ref_name, 'renovate-github-sh') }}
# Needed for nx-set-shas when run on the main branch
permissions:
actions: read
contents: write
pull-requests: write
env:
HUSKY: 0
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_DASHBOARD_KEY }}
NODE_OPTIONS: '--max_old_space_size=4096'
jobs:
main:
runs-on: ubuntu-latest
outputs:
shouldTriggerRelease: ${{ steps.shouldTriggerRelease.outputs.triggerRelease }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Debug print env variables
run: |
printenv
- uses: nrwl/nx-set-shas@v4
- run: |
echo "BASE: ${{ env.NX_BASE }}"
echo "HEAD: ${{ env.NX_HEAD }}"
# Connect your workspace on nx.app and uncomment this to enable task distribution.
# The "--stop-agents-after" is optional, but allows idle agents to shut down once the "e2e-ci" targets have been requested
- run: npx nx-cloud start-ci-run --distribute-on=".nx/workflows/dynamic-changesets.yml" --stop-agents-after="e2e-ci"
- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: 'npm'
- name: Install Deps
uses: ./.github/actions/install-deps
with:
cypress: 'true'
apt-packages: 'true'
# This line is needed for nx affected to work when CI is running on a PR
# - run: git branch --track main origin/main
# if: github.event_name == 'pull_request'
- run: npx nx-cloud record -- nx format:check
- run: npx nx affected -t=\"lint,test,build,component-test,e2e-ci\" -c=ci
- run: npx nx-cloud stop-all-agents
if: ${{ always() }}
- name: Report Codecov
if: github.ref_name == 'main' && hashFiles('coverage/**/*') != ''
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: unittests
fail_ci_if_error: true
verbose: true
- name: determine if deployables are affected and a release should be triggered
if: github.ref_name == 'main'
id: shouldTriggerRelease
run: |
projects=$(npx nx show projects --affected -t deploy);
echo $projects
triggerRelease=$([[ -z $projects ]] && echo "false" || echo "true")
echo "triggerRelease=$triggerRelease" >> $GITHUB_OUTPUT
echo "$([[ -z $projects ]] && echo 'No deployable projects affected, no need for a release' || echo 'Deployable projects affected. Trigger release!!!')" >> $GITHUB_STEP_SUMMARY
# as the main workflow is mandatory for the branch protection we need a separate job
trigger-release:
uses: ./.github/workflows/trigger-release.yml
secrets: inherit
needs: main
if: ${{ success() && needs.main.outputs.shouldTriggerRelease == 'true' && !contains(github.event.head_commit.message, 'chore(release):') && github.ref_name == 'main' }}