Check Integration OVA - #779 Update the deleted indexes in OVA and AMI builds #107
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| run-name: "Check Integration OVA - #${{ github.event.issue.number }} ${{ github.event.issue.title }}" | |
| name: Check Integration - OVA Build & Test | |
| on: | |
| issue_comment: | |
| types: [created] | |
| permissions: | |
| id-token: write | |
| contents: read | |
| pull-requests: write | |
| issues: write | |
| checks: write | |
| jobs: | |
| get_pr_info: | |
| if: | | |
| github.event.issue.pull_request && | |
| github.event.issue.state == 'open' && | |
| !github.event.issue.draft && | |
| (contains(github.event.comment.body, '/test-integration') || | |
| contains(github.event.comment.body, '/test-ova')) | |
| runs-on: ubuntu-latest | |
| outputs: | |
| pr_number: ${{ steps.pr_data.outputs.pr_number }} | |
| pr_head_ref: ${{ steps.pr_data.outputs.pr_head_ref }} | |
| pr_head_sha: ${{ steps.pr_data.outputs.pr_head_sha }} | |
| check_run_id: ${{ steps.create_check.outputs.result }} | |
| steps: | |
| - name: React to comment | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| await github.rest.reactions.createForIssueComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| comment_id: context.payload.comment.id, | |
| content: 'rocket' | |
| }); | |
| - name: Extract PR data | |
| id: pr_data | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| PR_NUMBER="${{ github.event.issue.number }}" | |
| # Fetch PR data from API | |
| PR_DATA=$(gh api repos/${{ github.repository }}/pulls/${PR_NUMBER}) | |
| PR_HEAD_REF=$(echo "$PR_DATA" | jq -r '.head.ref') | |
| PR_HEAD_SHA=$(echo "$PR_DATA" | jq -r '.head.sha') | |
| echo "pr_number=${PR_NUMBER}" >> $GITHUB_OUTPUT | |
| echo "pr_head_ref=${PR_HEAD_REF}" >> $GITHUB_OUTPUT | |
| echo "pr_head_sha=${PR_HEAD_SHA}" >> $GITHUB_OUTPUT | |
| echo "✅ PR: #${PR_NUMBER}" | |
| echo "✅ Branch: ${PR_HEAD_REF}" | |
| echo "✅ SHA: ${PR_HEAD_SHA}" | |
| - name: Create check run | |
| id: create_check | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const { data: check } = await github.rest.checks.create({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| name: 'OVA Build & Test', | |
| head_sha: '${{ steps.pr_data.outputs.pr_head_sha }}', | |
| status: 'in_progress', | |
| started_at: new Date().toISOString(), | |
| details_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`, | |
| output: { | |
| title: '🔨 Building OVA...', | |
| summary: `Triggered by comment: \`${{ github.event.comment.body }}\``, | |
| text: 'Building OVA image and running integration tests' | |
| } | |
| }); | |
| console.log('✅ Check run created:', check.id); | |
| return check.id; | |
| build_ova: | |
| needs: get_pr_info | |
| uses: ./.github/workflows/builder_OVA.yaml | |
| with: | |
| id: "pr-check-${{ needs.get_pr_info.outputs.pr_number }}" | |
| wazuh_virtual_machines_reference: ${{ needs.get_pr_info.outputs.pr_head_ref }} | |
| wazuh_automation_reference: 'main' | |
| is_stage: false | |
| ova_revision: "PR-${{ needs.get_pr_info.outputs.pr_number }}" | |
| wazuh_package_type: dev | |
| commit_list: '["latest", "latest", "latest", "latest", "latest"]' | |
| destroy: true | |
| checksum: false | |
| is_pr_check: true | |
| secrets: inherit | |
| test_ova: | |
| needs: [get_pr_info, build_ova] | |
| uses: ./.github/workflows/test-vm.yaml | |
| with: | |
| WAZUH_VIRTUAL_MACHINES_REFERENCE: ${{ needs.get_pr_info.outputs.pr_head_ref }} | |
| WAZUH_AUTOMATION_REFERENCE: 'main' | |
| test_type: ova | |
| wazuh_package_type: dev | |
| commit_list: '["latest", "latest", "latest", "latest", "latest"]' | |
| TESTS: ALL | |
| log_level: INFO | |
| ova_revision: ${{ needs.build_ova.outputs.ova_revision }} | |
| secrets: inherit | |
| update_check_success: | |
| needs: [get_pr_info, build_ova, test_ova] | |
| if: success() | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Update check - success | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| await github.rest.checks.update({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| check_run_id: ${{ needs.get_pr_info.outputs.check_run_id }}, | |
| status: 'completed', | |
| conclusion: 'success', | |
| completed_at: new Date().toISOString(), | |
| output: { | |
| title: '✅ OVA Build & Test - Success', | |
| summary: 'All tests passed!', | |
| text: ` | |
| ## Results | |
| - ✅ OVA built successfully | |
| - ✅ Integration tests passed | |
| [View workflow run](https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}) | |
| ` | |
| } | |
| }); | |
| update_check_failure: | |
| needs: [get_pr_info, build_ova, test_ova] | |
| if: failure() | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Update check - failure | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const buildStatus = '${{ needs.build_ova.result }}'; | |
| const testStatus = '${{ needs.test_ova.result }}'; | |
| await github.rest.checks.update({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| check_run_id: ${{ needs.get_pr_info.outputs.check_run_id }}, | |
| status: 'completed', | |
| conclusion: 'failure', | |
| completed_at: new Date().toISOString(), | |
| output: { | |
| title: '❌ OVA Build & Test - Failed', | |
| summary: 'One or more steps failed', | |
| text: ` | |
| ## Results | |
| - Build OVA: ${buildStatus} | |
| - Test OVA: ${testStatus} | |
| [View workflow run for details](https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}) | |
| ` | |
| } | |
| }); |