feat: copy charts from clients repo #22
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "Pull Request Labeler" | |
on: | |
pull_request: | |
types: [ assigned, opened, synchronize, reopened, labeled, unlabeled ] | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
labeler: | |
permissions: | |
contents: read | |
pull-requests: write | |
runs-on: formance-runner | |
steps: | |
- uses: 'actions/checkout@v4' | |
with: | |
fetch-depth: 0 | |
- uses: actions/labeler@v5 | |
with: | |
sync-labels: true | |
- name: Retrieve chart changes | |
id: chart_changes | |
run: | | |
CHARTS=$(git diff origin/main --stat | grep -oE 'charts/[^/]+/' | sed 's|charts/||;s|/||' | sort -u | jq -R -s -c 'split("\n") | map(select(. != ""))') | |
echo "Changed charts: $CHARTS" | |
echo "::set-output name=changed_charts::$CHARTS" | |
- name: Label PR based on chart changes | |
if: steps.chart_changes.outputs.changed_charts != '' | |
uses: actions/github-script@v7 | |
env: | |
CHARTS: ${{ steps.chart_changes.outputs.changed_charts }} | |
with: | |
script: | | |
const charts = JSON.parse(process.env.CHARTS); | |
const labels = charts.map(chart => `chart-${chart.trim()}`).filter(label => label.length > 0); | |
if (labels.length > 0) { | |
console.log(`Applying labels: ${labels.join(', ')}`); | |
await github.rest.issues.addLabels({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.issue.number, | |
labels: labels | |
}); | |
} else { | |
console.log('No charts changed, skipping labeling.'); | |
} |