|
19 | 19 | - '.github/workflows/on_push_to_master_test_and_deploy.yaml'
|
20 | 20 | - '.github/workflows/on_call_build_site.yaml'
|
21 | 21 | - '.github/workflows/on_call_staging_test.yaml'
|
| 22 | + - '.github/workflows/on_pr_test.yaml' |
22 | 23 | - 'package.json'
|
23 | 24 | - 'package-lock.json'
|
24 | 25 | - 'webpack.config.js'
|
|
58 | 59 | ${{ needs.detect_base_image_changes.outputs.changed == 'true'
|
59 | 60 | && github.event.number || '' }}
|
60 | 61 |
|
| 62 | + comment_docker_image: |
| 63 | + needs: [detect_base_image_changes, build_site] |
| 64 | + runs-on: ubuntu-latest |
| 65 | + # Only run if base image changes were detected and this is a PR event |
| 66 | + if: needs.detect_base_image_changes.outputs.changed == 'true' && github.event_name == 'pull_request' |
| 67 | + permissions: |
| 68 | + pull-requests: write # Allow commenting on PR |
| 69 | + steps: |
| 70 | + - name: Comment on PR with Docker image link |
| 71 | + uses: actions/github-script@v7 |
| 72 | + with: |
| 73 | + script: | |
| 74 | + const prNumber = context.issue.number; |
| 75 | + const imageTag = prNumber; |
| 76 | + const imageUrl = `ghcr.io/orionrobots/orionrobots-site.base:${imageTag}`; |
| 77 | + |
| 78 | + // Comment body with Docker image information |
| 79 | + const commentBody = `## 🐳 Docker Base Image Available |
| 80 | + |
| 81 | + A new base Docker image has been built and pushed for this PR: |
| 82 | + |
| 83 | + **Image:** \`${imageUrl}\` |
| 84 | + |
| 85 | + ### How to use this image: |
| 86 | + |
| 87 | + \`\`\`bash |
| 88 | + # Pull the image |
| 89 | + docker pull ${imageUrl} |
| 90 | + |
| 91 | + # Run with the image |
| 92 | + docker run -it ${imageUrl} bash |
| 93 | + \`\`\` |
| 94 | + |
| 95 | + ### For local development: |
| 96 | + You can use this image as a base for testing changes without rebuilding dependencies. |
| 97 | + |
| 98 | + _This comment is automatically updated when the base image is rebuilt._`; |
| 99 | + |
| 100 | + // Look for existing comment from this bot |
| 101 | + const comments = await github.rest.issues.listComments({ |
| 102 | + owner: context.repo.owner, |
| 103 | + repo: context.repo.repo, |
| 104 | + issue_number: prNumber, |
| 105 | + }); |
| 106 | + |
| 107 | + const botComment = comments.data.find(comment => |
| 108 | + comment.user.type === 'Bot' && |
| 109 | + comment.body.includes('🐳 Docker Base Image Available') |
| 110 | + ); |
| 111 | + |
| 112 | + if (botComment) { |
| 113 | + // Update existing comment |
| 114 | + await github.rest.issues.updateComment({ |
| 115 | + owner: context.repo.owner, |
| 116 | + repo: context.repo.repo, |
| 117 | + comment_id: botComment.id, |
| 118 | + body: commentBody |
| 119 | + }); |
| 120 | + console.log('Updated existing Docker image comment'); |
| 121 | + } else { |
| 122 | + // Create new comment |
| 123 | + await github.rest.issues.createComment({ |
| 124 | + owner: context.repo.owner, |
| 125 | + repo: context.repo.repo, |
| 126 | + issue_number: prNumber, |
| 127 | + body: commentBody |
| 128 | + }); |
| 129 | + console.log('Created new Docker image comment'); |
| 130 | + } |
| 131 | +
|
61 | 132 | staging_test:
|
62 | 133 | uses: ./.github/workflows/on_call_staging_test.yaml
|
63 | 134 | needs: build_site
|
0 commit comments