Skip to content

feat: copy charts from clients repo #21

feat: copy charts from clients repo

feat: copy charts from clients repo #21

Workflow file for this run

name: Main
on:
merge_group:
pull_request:
types: [ assigned, opened, synchronize, reopened, labeled, unlabeled ]
push:
branches:
- main
- v*.*.*
jobs:
labeler:
name: Chart Diff 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.');
}
pr_name:
if: github.event_name == 'pull_request'
name: Check PR Title
runs-on: formance-runner
permissions:
statuses: write
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
tests:
name: Tests Charts
timeout-minutes: 2
runs-on: formance-runner
needs: chart_any
steps:
- uses: 'actions/checkout@v4'
with:
fetch-depth: 0
- name: Tests
run: earthly +tests
chart_any:
name: Any Chart
timeout-minutes: 1
runs-on: formance-runner
needs: chart_matrix_labels
strategy:
matrix:
chart: ${{ fromJson(needs.chart_matrix_labels.outputs.charts) }}
steps:
- uses: 'actions/checkout@v4'
with:
fetch-depth: 0
- uses: ./.github/actions/helm/anychart
with:
CHART_NAME: ${{ matrix.chart }}
CHART_DIR: charts
chart_matrix_labels:
if: github.event.pull_request.labels != ''
name: Check for Labels
needs: readme
timeout-minutes: 1
runs-on: formance-runner
outputs:
charts: ${{ steps.set-matrix.outputs.charts }}
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Check for Labels
id: set-matrix
run: |
# Extract labels and filter chart labels
CHART_LABELS=$(echo '${{ toJSON(github.event.pull_request.labels) }}' | jq -r '.[].name | select(startswith("chart-")) | sub("chart-"; "")' | jq -R -s -c 'split("\n") | map(select(. != ""))')
# Set the output to be used in the next job
echo "charts=${CHART_LABELS}"
echo "charts=${CHART_LABELS}" >> $GITHUB_OUTPUT
readme:
name: Readme
timeout-minutes: 1
needs: labeler
runs-on: formance-runner
steps:
- uses: 'actions/checkout@v4'
with:
fetch-depth: 0
- name: Base Earthly action
uses: ./.github/actions/earthly/base
- name: Readme
run: earthly +readme
- name: Dirty
uses: ./.github/actions/github/dirty