name: ApprovalComment
on:
  pull_request_review:
    types: [submitted]
jobs:
  approval-comment:
    if: startsWith(github.event.review.body, '/karpenter snapshot') || startsWith(github.event.review.body, '/karpenter scale') || startsWith(github.event.review.body, '/karpenter versionCompatibility')
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
        with:
          fetch-depth: 0
      - name: Save info about the review comment as an artifact for other workflows that run on workflow_run to download them
        env:
          REVIEW_BODY: ${{ github.event.review.body }}
          PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }}
          COMMIT_ID: ${{ github.event.review.commit_id }}
        run: |
          mkdir -p /tmp/artifacts
          { echo "$REVIEW_BODY"; echo "$PULL_REQUEST_NUMBER"; echo "$COMMIT_ID"; } >> /tmp/artifacts/metadata.txt
          cat /tmp/artifacts/metadata.txt
      - uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
        with:
          name: artifacts
          path: /tmp/artifacts
