From f774192b824f2f1d41d437ee64e318471981462e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Skyler=20M=C3=A4ntysaari?= Date: Wed, 19 Apr 2023 04:17:50 +0300 Subject: [PATCH] CI: More CI workflows. --- .github/workflows/pr-metadata.yaml | 77 ++++++++++++++++++++++++++++++ .github/workflows/pr-validate.yaml | 30 ++++++++++++ 2 files changed, 107 insertions(+) create mode 100644 .github/workflows/pr-metadata.yaml create mode 100644 .github/workflows/pr-validate.yaml diff --git a/.github/workflows/pr-metadata.yaml b/.github/workflows/pr-metadata.yaml new file mode 100644 index 0000000..2cdcb1d --- /dev/null +++ b/.github/workflows/pr-metadata.yaml @@ -0,0 +1,77 @@ +name: "Pull Request: Get metadata" + +on: + workflow_call: + outputs: + isRenovatePR: + description: "Is the PR coming from Renovate?" + value: ${{ jobs.pr-metadata.outputs.isRenovatePR }} + isFork: + description: "Is the PR coming from a forked repo?" + value: ${{ jobs.pr-metadata.outputs.isFork }} + addedOrModifiedFilesDetected: + description: "Does the PR contain any changes?" + value: ${{ jobs.pr-changes.outputs.addedOrModifiedFilesDetected }} + addedOrModifiedFiles: + description: "A list of the files changed in this PR" + value: ${{ jobs.pr-changes.outputs.addedOrModifiedFiles }} + addedOrModifiedCharts: + description: "A list of the charts changed in this PR" + value: ${{ jobs.pr-changes.outputs.addedOrModifiedCharts }} + chartsToLint: + value: ${{ jobs.pr-changes.outputs.chartsToLint }} + chartsToInstall: + value: ${{ jobs.pr-changes.outputs.chartsToInstall }} + +jobs: + pr-metadata: + name: Collect PR metadata + runs-on: ubuntu-latest + outputs: + isRenovatePR: ${{ startsWith(steps.branch-name.outputs.current_branch, 'renovate/') }} + isFork: ${{ github.event.pull_request.head.repo.full_name != github.repository }} + steps: + - name: Get branch name + id: branch-name + uses: tj-actions/branch-names@v6.5 + + - name: Save PR data to file + env: + PR_NUMBER: ${{ github.event.number }} + run: | + echo $PR_NUMBER > pr_number.txt + + - name: Store pr data in artifact + uses: actions/upload-artifact@v3 + with: + name: pr_metadata + path: ./pr_number.txt + retention-days: 5 + + pr-changes: + name: Collect PR changes + runs-on: ubuntu-latest + outputs: + addedOrModifiedFilesDetected: ${{ steps.changed-files.outputs.allAddedOrModified }} + addedOrModifiedFiles: ${{ steps.changed-files.outputs.allAddedOrModified_files }} + addedOrModifiedCharts: ${{ steps.changed-charts.outputs.charts }} + chartsToLint: ${{ steps.changed-charts.outputs.chartsToLint }} + chartsToInstall: ${{ steps.changed-charts.outputs.chartsToInstall }} + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Collect changed files + uses: dorny/paths-filter@v2 + id: changed-files + with: + list-files: json + filters: | + allAddedOrModified: + - added|modified: '**' + + - name: Collect changed charts + uses: bjw-s/helm-charts-actions/collect-charts@main + id: changed-charts diff --git a/.github/workflows/pr-validate.yaml b/.github/workflows/pr-validate.yaml new file mode 100644 index 0000000..2fb41b9 --- /dev/null +++ b/.github/workflows/pr-validate.yaml @@ -0,0 +1,30 @@ +name: "Pull Request: Validate" + +on: + pull_request: + workflow_dispatch: + +concurrency: + group: ${{ github.head_ref }}-pr-validate + cancel-in-progress: true + +jobs: + pr-metadata: + uses: ./.github/workflows/pr-metadata.yaml + + charts-changelog: + uses: ./.github/workflows/charts-changelog.yaml + needs: + - pr-metadata + with: + isRenovatePR: ${{ needs.pr-metadata.outputs.isRenovatePR }} + modifiedCharts: ${{ needs.pr-metadata.outputs.addedOrModifiedCharts }} + + charts-lint: + uses: ./.github/workflows/charts-lint.yaml + needs: + - pr-metadata + with: + checkoutCommit: ${{ github.sha }} + chartsToLint: ${{ needs.pr-metadata.outputs.chartsToLint }} + isRenovatePR: ${{ needs.pr-metadata.outputs.isRenovatePR }}