diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index e25a360d50..b0d695b1c7 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -133,3 +133,36 @@ jobs: - uses: actions/checkout@v4 - uses: projectdiscovery/actions/setup/go@v1 - uses: projectdiscovery/actions/goreleaser@v1 + + flamegraph: + name: "Flamegraph" + needs: ["tests"] + env: + PROFILE_MEM: "/tmp/nuclei" + TARGET_URL: "http://scanme.sh/a/?b=c" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - run: make build + - name: "Setup environment (push)" + if: ${{ github.event_name == 'push' }} + run: | + echo "PROFILE_MEM=${PROFILE_MEM}-${GITHUB_REF_NAME}-${GITHUB_SHA}" >> $GITHUB_ENV + echo "FLAMEGRAPH_NAME=nuclei-${GITHUB_REF_NAME} (${GITHUB_SHA})" >> $GITHUB_ENV + - name: "Setup environment (pull_request)" + if: ${{ github.event_name == 'pull_request' }} + run: | + echo "PROFILE_MEM=${PROFILE_MEM}-pr-${{ github.event.number }}" >> $GITHUB_ENV + echo "FLAMEGRAPH_NAME=nuclei (PR #${{ github.event.number }})" >> $GITHUB_ENV + - run: ./bin/nuclei -silent -update-templates + - run: ./bin/nuclei -silent -u "${TARGET_URL}" -profile-mem="${PROFILE_MEM}" + - uses: projectdiscovery/actions/flamegraph@master + id: flamegraph + with: + profile: "${{ env.PROFILE_MEM }}.prof" + name: "${{ env.FLAMEGRAPH_NAME }}" + continue-on-error: true + - if: ${{ steps.flamegraph.outputs.message == '' }} + run: echo "::notice::${FLAMEGRAPH_URL}" + env: + FLAMEGRAPH_URL: ${{ steps.flamegraph.outputs.url }}