|
| 1 | +name: "Post Maestro Screenshot" |
| 2 | +description: "Posts the final Maestro test screenshot using external image hosting" |
| 3 | +inputs: |
| 4 | + platform: |
| 5 | + description: "Platform (ios or android)" |
| 6 | + required: true |
| 7 | + github-token: |
| 8 | + description: "GitHub token for posting comments" |
| 9 | + required: true |
| 10 | + default: ${{ github.token }} |
| 11 | + test-outcome: |
| 12 | + description: "Test outcome (success or failure)" |
| 13 | + required: false |
| 14 | + default: "unknown" |
| 15 | + imgbb-api-key: |
| 16 | + description: "ImgBB API key for image hosting" |
| 17 | + required: true |
| 18 | + |
| 19 | +runs: |
| 20 | + using: "composite" |
| 21 | + steps: |
| 22 | + - name: Check if screenshot exists |
| 23 | + id: check-screenshot |
| 24 | + shell: bash |
| 25 | + run: | |
| 26 | + SS_FILE="/tmp/e2e-output/${{ inputs.platform }}-tests-completed.png" |
| 27 | + if [ -f "$SS_FILE" ]; then |
| 28 | + echo "exists=true" >> $GITHUB_OUTPUT |
| 29 | + echo "file_path=$SS_FILE" >> $GITHUB_OUTPUT |
| 30 | + echo "Screenshot found at $SS_FILE" |
| 31 | + else |
| 32 | + echo "exists=false" >> $GITHUB_OUTPUT |
| 33 | + echo "Screenshot not found at $SS_FILE" |
| 34 | + fi |
| 35 | +
|
| 36 | + - name: Upload screenshot to ImgBB |
| 37 | + if: steps.check-screenshot.outputs.exists == 'true' && github.event_name == 'pull_request' |
| 38 | + id: upload-screenshot |
| 39 | + uses: McCzarny/upload-image@v2.0.0 |
| 40 | + with: |
| 41 | + path: ${{ steps.check-screenshot.outputs.file_path }} |
| 42 | + upload-method: imgbb |
| 43 | + api-key: ${{ inputs.imgbb-api-key }} |
| 44 | + expiration: 2592000 # 30 days |
| 45 | + |
| 46 | + - name: Find Comment |
| 47 | + uses: peter-evans/find-comment@v3 |
| 48 | + id: find-comment |
| 49 | + if: github.event_name == 'pull_request' |
| 50 | + with: |
| 51 | + issue-number: ${{ github.event.pull_request.number }} |
| 52 | + comment-author: "github-actions[bot]" |
| 53 | + body-includes: End-to-End Test Results - ${{ inputs.platform == 'ios' && 'iOS' || 'Android' }} |
| 54 | + |
| 55 | + - name: Create or update PR comment (with screenshot) |
| 56 | + if: github.event_name == 'pull_request' && steps.check-screenshot.outputs.exists == 'true' && steps.upload-screenshot.outputs.url |
| 57 | + uses: peter-evans/create-or-update-comment@v4 |
| 58 | + with: |
| 59 | + token: ${{ inputs.github-token }} |
| 60 | + issue-number: ${{ github.event.pull_request.number }} |
| 61 | + comment-id: ${{ steps.find-comment.outputs.comment-id }} |
| 62 | + body: | |
| 63 | + ## 🤖 End-to-End Test Results - ${{ inputs.platform == 'ios' && 'iOS' || 'Android' }} |
| 64 | +
|
| 65 | + **Status**: ${{ inputs.test-outcome == 'success' && '✅ Passed' || '❌ Failed' }} |
| 66 | + **Platform**: ${{ inputs.platform == 'ios' && 'iOS' || 'Android' }} |
| 67 | + **Run**: [${{ github.run_id }}](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) |
| 68 | +
|
| 69 | + ### 📸 Final Test Screenshot |
| 70 | +
|
| 71 | + <img width="600" alt="Maestro Test Results - ${{ inputs.platform }}" src="${{ steps.upload-screenshot.outputs.url }}" /> |
| 72 | +
|
| 73 | + *Screenshot automatically captured from End-to-End tests and will expire in 30 days* |
| 74 | +
|
| 75 | + --- |
| 76 | + *This comment is automatically updated on each test run.* |
| 77 | + edit-mode: replace |
| 78 | + |
| 79 | + - name: Create or update PR comment (no screenshot) |
| 80 | + if: github.event_name == 'pull_request' && steps.check-screenshot.outputs.exists != 'true' |
| 81 | + uses: peter-evans/create-or-update-comment@v4 |
| 82 | + with: |
| 83 | + token: ${{ inputs.github-token }} |
| 84 | + issue-number: ${{ github.event.pull_request.number }} |
| 85 | + comment-id: ${{ steps.find-comment.outputs.comment-id }} |
| 86 | + body: | |
| 87 | + ## 🤖 End-to-End Test Results - ${{ inputs.platform == 'ios' && 'iOS' || 'Android' }} |
| 88 | +
|
| 89 | + **Status**: ${{ inputs.test-outcome == 'success' && '✅ Passed' || '❌ Failed' }} |
| 90 | + **Platform**: ${{ inputs.platform == 'ios' && 'iOS' || 'Android' }} |
| 91 | + **Run**: [${{ github.run_id }}](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) |
| 92 | +
|
| 93 | + ### 📸 Final Test Screenshot |
| 94 | +
|
| 95 | + ⚠️ No final screenshot available |
| 96 | +
|
| 97 | + --- |
| 98 | + *This comment is automatically updated on each test run.* |
| 99 | + edit-mode: replace |
| 100 | + |
| 101 | + - name: Create or update PR comment (upload failed) |
| 102 | + if: github.event_name == 'pull_request' && steps.check-screenshot.outputs.exists == 'true' && !steps.upload-screenshot.outputs.url |
| 103 | + uses: peter-evans/create-or-update-comment@v4 |
| 104 | + with: |
| 105 | + token: ${{ inputs.github-token }} |
| 106 | + issue-number: ${{ github.event.pull_request.number }} |
| 107 | + comment-id: ${{ steps.find-comment.outputs.comment-id }} |
| 108 | + body: | |
| 109 | + ## 🤖 End-to-End Test Results - ${{ inputs.platform == 'ios' && 'iOS' || 'Android' }} |
| 110 | +
|
| 111 | + **Status**: ${{ inputs.test-outcome == 'success' && '✅ Passed' || '❌ Failed' }} |
| 112 | + **Platform**: ${{ inputs.platform == 'ios' && 'iOS' || 'Android' }} |
| 113 | + **Run**: [${{ github.run_id }}](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) |
| 114 | +
|
| 115 | + ### 📸 Final Test Screenshot |
| 116 | +
|
| 117 | + ⚠️ Screenshot was captured but failed to upload. Check workflow logs for details. |
| 118 | +
|
| 119 | + --- |
| 120 | + *This comment is automatically updated on each test run.* |
| 121 | + edit-mode: replace |
| 122 | + |
| 123 | + - name: Log screenshot status |
| 124 | + shell: bash |
| 125 | + run: | |
| 126 | + if [ "${{ steps.check-screenshot.outputs.exists }}" = "true" ]; then |
| 127 | + if [ -n "${{ steps.upload-screenshot.outputs.url }}" ]; then |
| 128 | + echo "✅ Screenshot uploaded and embedded in PR comment for ${{ inputs.platform }}" |
| 129 | + echo "🔗 Image URL: ${{ steps.upload-screenshot.outputs.url }}" |
| 130 | + echo "🗑️ Delete URL: ${{ steps.upload-screenshot.outputs.delete-url }}" |
| 131 | + else |
| 132 | + echo "❌ Screenshot upload failed for ${{ inputs.platform }}" |
| 133 | + fi |
| 134 | + else |
| 135 | + echo "⚠️ No screenshot found for ${{ inputs.platform }}" |
| 136 | + fi |
0 commit comments