|
11 | 11 | jobs: |
12 | 12 | build-preview: |
13 | 13 | runs-on: ubuntu-latest |
| 14 | + # Temporarily disabled to avoid duplicate comments with pr-preview.yml |
| 15 | + # Both workflows provide similar functionality, pr-preview.yml is more comprehensive |
| 16 | + if: false |
14 | 17 | steps: |
15 | 18 | - name: Checkout code |
16 | 19 | uses: actions/checkout@v4 |
@@ -60,27 +63,54 @@ jobs: |
60 | 63 | uses: actions/github-script@v7 |
61 | 64 | with: |
62 | 65 | script: | |
| 66 | + const prNumber = context.issue.number; |
| 67 | + const runId = context.runId; |
| 68 | +
|
63 | 69 | const comment = `🔨 **Preview Build Complete!** |
64 | 70 |
|
65 | | - Your changes have been built successfully. To test locally: |
| 71 | + Your changes have been built successfully. |
66 | 72 |
|
| 73 | + **📦 Download & Test Locally:** |
| 74 | + 1. [📁 Download Docker Image Artifact](https://github.com/${{ github.repository }}/actions/runs/${runId}) (look for \`wrongsecrets-preview-${prNumber}\`) |
| 75 | + 2. Load and run the image: |
67 | 76 | \`\`\`bash |
68 | | - # Download the artifact and load the Docker image |
| 77 | + # Download the artifact, extract it, then: |
69 | 78 | docker load < wrongsecrets-preview.tar |
70 | 79 | docker run -p 8080:8080 wrongsecrets-preview |
71 | 80 | \`\`\` |
72 | 81 |
|
73 | 82 | Then visit: http://localhost:8080 |
74 | 83 |
|
75 | | - **Changed Files in this PR:** |
76 | | - - Templates: ${{ github.event.pull_request.changed_files }} |
| 84 | + **📝 Changed Files in this PR:**`; |
| 85 | +
|
| 86 | + // Get the list of changed files |
| 87 | + const { data: files } = await github.rest.pulls.listFiles({ |
| 88 | + owner: context.repo.owner, |
| 89 | + repo: context.repo.repo, |
| 90 | + pull_number: prNumber |
| 91 | + }); |
| 92 | +
|
| 93 | + const templateFiles = files.filter(file => |
| 94 | + file.filename.includes('templates/') || |
| 95 | + file.filename.includes('static/') || |
| 96 | + file.filename.includes('explanations/') |
| 97 | + ); |
| 98 | +
|
| 99 | + let filesList = ''; |
| 100 | + if (templateFiles.length > 0) { |
| 101 | + filesList = templateFiles.map(file => `- \`${file.filename}\``).join('\\n '); |
| 102 | + } else { |
| 103 | + filesList = '- No template/static files changed'; |
| 104 | + } |
| 105 | +
|
| 106 | + const fullComment = comment + '\\n ' + filesList + ` |
77 | 107 |
|
78 | 108 | --- |
79 | 109 | <sub>Build completed by GitHub Actions</sub>`; |
80 | 110 |
|
81 | 111 | github.rest.issues.createComment({ |
82 | | - issue_number: context.issue.number, |
| 112 | + issue_number: prNumber, |
83 | 113 | owner: context.repo.owner, |
84 | 114 | repo: context.repo.repo, |
85 | | - body: comment |
| 115 | + body: fullComment |
86 | 116 | }); |
0 commit comments