@@ -154,15 +154,14 @@ jobs:
154154 export :
155155 name : Publish PR Dynamic Plugin Images
156156 needs :
157- - parse
158157 - prepare
159158 - checkPRUpToDate
160159
161160 concurrency :
162161 group : export-${{ github.ref_name }}-${{ github.event.issue.number }}
163162 cancel-in-progress : true
164163
165- if : needs.parse.outputs.command_name == 'publish' && needs.prepare.outputs.overlay-branch != '' && needs.prepare.outputs.workspace != ''
164+ if : github.event.comment.body == '/ publish' && needs.prepare.outputs.overlay-branch != '' && needs.prepare.outputs.workspace != ''
166165
167166 uses : redhat-developer/rhdh-plugin-export-utils/.github/workflows/export-workspaces-as-dynamic.yaml@main
168167 with :
@@ -183,6 +182,65 @@ jobs:
183182 packages : write
184183 id-token : write
185184
185+ updateTestConfig :
186+ runs-on : ubuntu-latest
187+ name : Update Test Config with Published OCI References
188+ needs :
189+ - prepare
190+ - export
191+
192+ concurrency :
193+ group : updateTestConfig-${{ github.ref_name }}-${{ github.event.issue.number }}
194+ cancel-in-progress : true
195+
196+ if : github.event.comment.body == '/publish' && needs.prepare.outputs.overlay-branch != '' && needs.prepare.outputs.workspace != '' && needs.export.outputs.published-exports != ''
197+
198+ steps :
199+ - name : Checkout
200+ uses : actions/checkout@v4
201+ with :
202+ ref : ${{ needs.prepare.outputs.overlay-branch }}
203+ repository : ${{ needs.prepare.outputs.overlay-repo }}
204+
205+ - name : Update dynamic-plugins.test.yaml
206+ env :
207+ PUBLISHED_EXPORTS : ${{ needs.export.outputs.published-exports }}
208+ PR_NUMBER : ${{ needs.prepare.outputs.pr-number }}
209+ WORKSPACE : ${{ needs.prepare.outputs.workspace }}
210+ run : |
211+ # Parse the published exports to get the OCI image reference
212+ echo "Published exports: $PUBLISHED_EXPORTS"
213+
214+ # Extract plugin name and version from the published exports
215+ # Format is expected to be like: ghcr.io/<repo>:pr_<PR#>__<plugin_version>
216+ for export in $PUBLISHED_EXPORTS; do
217+ if [[ "$export" =~ ghcr\.io/([^:]+):pr_${PR_NUMBER}__(.+) ]]; then
218+ IMAGE_REPO="${BASH_REMATCH[1]}"
219+ PLUGIN_VERSION="${BASH_REMATCH[2]}"
220+
221+ # Get plugin name from workspace path
222+ PLUGIN_NAME=$(basename "$WORKSPACE")
223+
224+ # Construct the OCI reference
225+ OCI_REF="oci://ghcr.io/${IMAGE_REPO}:pr_${PR_NUMBER}__${PLUGIN_VERSION}!backstage-community-plugin-${PLUGIN_NAME}"
226+
227+ # Update the test file if it exists
228+ TEST_FILE="${WORKSPACE}/tests/dynamic-plugins.test.yaml"
229+ if [ -f "$TEST_FILE" ]; then
230+ echo "Updating $TEST_FILE with OCI reference: $OCI_REF"
231+ sed -i "s|package: oci://.*|package: ${OCI_REF}|" "$TEST_FILE"
232+ fi
233+ fi
234+ done
235+
236+ - name : Commit and push changes
237+ run : |
238+ git config --local user.email "[email protected] " 239+ git config --local user.name "GitHub Action"
240+ git add -A
241+ git diff --staged --quiet || git commit -m "Update test config with PR OCI references"
242+ git push
243+
186244 checkBackstageCompatibility :
187245 name : Check workspace backstage compatibility
188246 needs :
@@ -207,6 +265,7 @@ jobs:
207265 - prepare
208266 - checkPRUpToDate
209267 - export
268+ - updateTestConfig
210269 - checkBackstageCompatibility
211270
212271 concurrency :
@@ -241,7 +300,7 @@ jobs:
241300 filter: 'latest',
242301 });
243302 const success = jobs.data.jobs
244- .filter(j => j.name.startsWith('Publish') || j.name.startsWith('export') || j.name.startsWith('Export') || j.name.startsWith('Check'))
303+ .filter(j => j.name.startsWith('Publish') || j.name.startsWith('export') || j.name.startsWith('Export') || j.name.startsWith('Check') || j.name.startsWith('Update Test Config') )
245304 .every(j => j.conclusion === 'success');
246305
247306 await github.rest.repos.createCommitStatus({
0 commit comments