Repository navigation
89 lines (79 loc) · 3.25 KB
/
Copy pathshared-detect-pkg-changes.yaml
File metadata and controls
89 lines (79 loc) · 3.25 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
# Run it locally with act (https://github.com/nektos/act)
# 1. Install act:
# `brew install act`
# 2. Create a .secret file with the following content:
# `GITHUB_TOKEN=your_github_token`
# PULL REQUEST
# 1. Create a act_pull_request.json file in case of a pull request with the following content:
# `{"inputs": {"paths": "packages/juno-ui-components apps/exampleapp", "node": "20.x", "runs-on": "ubuntu-latest"}}`
# 2. Run the following command:
# `act workflow_call -e act_workflow_call_ci.json -W .github/workflows/check-changes-npm-package.yaml`
name: Detect Changes on the given Paths or Folders
on:
workflow_call:
inputs:
paths:
description: "Space separated list of paths indicating where to collect packages to be check for changes. Example: 'packages' will check all packages in the packages folder."
required: false
type: string
folders:
description: "Space-separated list of folders to be checked for changes. Example: 'packages/communicator packages/juno-ui-components' checks for changes in the communicator and juno-ui-components packages. You can use wildcards to check all packages within a specific folder. Example: '*/ui' checks all packages with a ui folder at the second level."
required: false
type: string
runs-on:
description: "The runner to use for the job"
required: false
default: "ubuntu-latest"
type: string
outputs:
changes:
description: "List of found changes in the paths"
value: ${{ jobs.detect-changes.outputs.changes }}
permissions:
contents: read
jobs:
detect-changes:
runs-on: ${{ inputs.runs-on}}
outputs:
changes: ${{ steps.package-filters.outputs.changes}}
steps:
- name: Print Inputs
run: |
echo "====${{ github.workflow }} Inputs===="
echo "Inputs: ${{ toJson(inputs) }}"
echo "===="
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Generate filters
id: generate-filters
run: |
items=()
echo "" > package_filters.yaml
if [ -n "${{ inputs.paths }}" ]; then
# Create a filter for each folder/package in the paths
for path in ${{ inputs.paths }}; do
for folder in $path/*; do
echo "$folder: $folder/**" >> package_filters.yaml
done
done
fi
if [ -n "${{ inputs.folders }}" ]; then
# Create a filter for each folder
for folder in ${{ inputs.folders }}; do
echo "$folder: $folder/**" >> package_filters.yaml
done
fi
- name: Set specific filters for the packages wihtin the paths
uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3
id: package-filters
with:
list-files: json
filters: package_filters.yaml
- name: Show outputs
run: |
echo "===${{ github.workflow }} Outputs==="
echo "====Package filters===="
cat package_filters.yaml
echo "========"
echo changed packages: ${{ steps.package-filters.outputs.changes}}
echo "===================="