diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 9e0649d8..f925257a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -2,7 +2,7 @@ name: Build Plugins PR on: pull_request: - branches: [ main ] + branches: [main] # Checks if any concurrent jobs under the same pull request or branch are being executed # NOTE: this will cancel every workflow that is being ran against a PR as group is just the github ref (without the workflow name) @@ -10,7 +10,7 @@ concurrency: group: ci-${{ github.head_ref || github.run_id }} cancel-in-progress: true -jobs: +jobs: build-plugins: uses: ./.github/workflows/reusable_build_packages.yaml with: @@ -20,7 +20,7 @@ jobs: get-changed-plugins: uses: ./.github/workflows/reusable_get_changed_plugins.yaml - + build-rules-tool: needs: [get-changed-plugins] if: needs.get-changed-plugins.outputs.changed-plugins != '[]' && needs.get-changed-plugins.outputs.changed-plugins != '' @@ -28,7 +28,7 @@ jobs: with: output: rules-checker repository: falcosecurity/rules - + validate-plugins: needs: [build-plugins, get-changed-plugins, build-rules-tool] if: needs.get-changed-plugins.outputs.changed-plugins != '[]' && needs.get-changed-plugins.outputs.changed-plugins != '' @@ -44,7 +44,7 @@ jobs: plugins-artifact: plugins-x86_64-${{ github.event.number }}.tar.gz rules-checker: ./rules-checker arch: x86_64 - + suggest-rules-version: needs: [build-plugins, get-changed-plugins, build-rules-tool] if: needs.get-changed-plugins.outputs.changed-plugins != '[]' && needs.get-changed-plugins.outputs.changed-plugins != '' @@ -60,3 +60,8 @@ jobs: rules-checker: ./rules-checker arch: x86_64 job-index: ${{ strategy.job-index }} + + upload-pr-info: + needs: [suggest-rules-version] + if: needs.get-changed-plugins.outputs.changed-plugins != '[]' && needs.get-changed-plugins.outputs.changed-plugins != '' + uses: ./.github/workflows/reusable_upload_pr_info.yaml diff --git a/.github/workflows/reusable_suggest_rules_version.yaml b/.github/workflows/reusable_suggest_rules_version.yaml index 8553272c..12a558ac 100644 --- a/.github/workflows/reusable_suggest_rules_version.yaml +++ b/.github/workflows/reusable_suggest_rules_version.yaml @@ -120,37 +120,3 @@ jobs: name: pr-${{ inputs.job-index }} path: pr/ retention-days: 1 - - upload-pr-info: - needs: [check-version] - if: github.event_name == 'pull_request' - runs-on: ubuntu-latest - steps: - - name: Download PR infos - uses: actions/download-artifact@v4 - with: - path: tmp-artifacts - - - name: Save PR info - run: | - mkdir -p ./pr - echo ${{ github.event.number }} > ./pr/NR - touch ./pr/COMMENT - echo "# Rules files suggestions" >> ./pr/COMMENT - echo "" >> ./pr/COMMENT - files=$(find ./tmp-artifacts/) - for file in $files; do - if [[ $file =~ "COMMENT" ]]; then - cat $file >> ./pr/COMMENT - fi - done - echo Uploading PR info... - cat ./pr/COMMENT - echo "" - - - name: Upload PR info as artifact - uses: actions/upload-artifact@v4 - with: - name: pr - path: pr/ - retention-days: 1 diff --git a/.github/workflows/reusable_upload_pr_info.yaml b/.github/workflows/reusable_upload_pr_info.yaml new file mode 100644 index 00000000..743ae47c --- /dev/null +++ b/.github/workflows/reusable_upload_pr_info.yaml @@ -0,0 +1,37 @@ +# This is a reusable workflow used by the PR CI +on: + workflow_call: + +jobs: + upload-pr-info: + if: github.event_name == 'pull_request' + runs-on: ubuntu-latest + steps: + - name: Download PR infos + uses: actions/download-artifact@v4 + with: + path: tmp-artifacts + + - name: Save PR info + run: | + mkdir -p ./pr + echo ${{ github.event.number }} > ./pr/NR + touch ./pr/COMMENT + echo "# Rules files suggestions" >> ./pr/COMMENT + echo "" >> ./pr/COMMENT + files=$(find ./tmp-artifacts/) + for file in $files; do + if [[ $file =~ "COMMENT" ]]; then + cat $file >> ./pr/COMMENT + fi + done + echo Uploading PR info... + cat ./pr/COMMENT + echo "" + + - name: Upload PR info as artifact + uses: actions/upload-artifact@v4 + with: + name: pr + path: pr/ + retention-days: 1