-
Notifications
You must be signed in to change notification settings - Fork 33
68 lines (60 loc) · 1.95 KB
/
nx.template.yaml
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
name: _Reusable nx template
on:
workflow_call:
inputs:
nx-head:
type: string
description: Commit SHA, branch or tag name used by Nx in the affected jobs as head.
required: true
nx-base:
type: string
description: Commit SHA, branch or tag name used by Nx in the affected jobs as base.
required: true
outputs:
affected-plugins:
description: Nx plugins affected by the changes
value: ${{ jobs.nx.outputs.affected-plugins }}
env:
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
NX_BRANCH: ${{ github.event.workflow_run.head_branch }}
BRANCH: ${{ github.event.workflow_run.head_branch }}
jobs:
nx:
name: Nx Affected Publishable Plugins
runs-on: ubuntu-20.04
outputs:
affected-plugins: ${{ steps.calculate-affected.outputs.affected-plugins }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ inputs.nx-head }}
filter: blob:none
- name: Nx set sha
uses: nrwl/nx-set-shas@v4
with:
main-branch-name: ${{ inputs.nx-base }}
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version-file: "package.json"
cache: "npm"
cache-dependency-path: "package-lock.json"
- name: Install dependencies
run: npm ci
- name: Get changed files
id: files
uses: tj-actions/changed-files@v42
with:
files_ignore: |
package.json
package-lock.json
.eslintrc*
nx.json
base_sha: ${{ env.NX_BASE }}
separator: ","
- name: Evaluate affected projects
id: calculate-affected
run: |
echo affected-plugins=$(npx nx show projects --affected --with-target npm:publish --json --files=${{ steps.files.outputs.all_changed_files }}) >> $GITHUB_OUTPUT
cat $GITHUB_OUTPUT | grep affected