-
Notifications
You must be signed in to change notification settings - Fork 9
37 lines (35 loc) · 1.1 KB
/
get-changed-charts.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
name: Get changed charts in PR
on:
workflow_call:
inputs:
pr_number:
type: number
required: true
outputs:
charts:
description: The names of the changed charts in the PR
value: ${{ jobs.getChangedCharts.outputs.charts }}
count:
value: ${{ jobs.getChangedCharts.outputs.count }}
jobs:
getChangedCharts:
runs-on: ubuntu-latest
outputs:
charts: ${{ steps.getCharts.outputs.charts }}
count: ${{ steps.getCharts.outputs.count }}
permissions:
pull-requests: read
steps:
- name: Get all charts
id: getCharts
env:
PULL_REQUEST_NUMBER: ${{ inputs.pr_number }}
GITHUB_TOKEN: ${{ github.token }}
run: |
set -e
set -o pipefail
charts="$(gh api --paginate "/repos/${GITHUB_REPOSITORY}/pulls/${PULL_REQUEST_NUMBER}/files" | jq -cr 'map(.filename | select(test("charts/[^/]*")) | split("/") | .[1] | select(.)) | unique')"
(
echo charts="$charts"
echo count="$(<<<"$charts" jq -r length)"
) | tee -a "$GITHUB_OUTPUT"