Skip to content

Add conditioning steering to z_image_turbo template #577

Add conditioning steering to z_image_turbo template

Add conditioning steering to z_image_turbo template #577

name: Check Input Assets
on:
pull_request:
paths:
- 'templates/**/*.json'
- 'input/**'
- 'scripts/check_input_assets.py'
- '.github/workflows/check_input_assets.yml'
permissions:
pull-requests: write
contents: read
jobs:
validate-input-assets:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Run input assets validation
id: validation
run: |
# Run validation and capture exit code
if python scripts/check_input_assets.py; then
echo "validation_failed=false" >> $GITHUB_OUTPUT
else
echo "validation_failed=true" >> $GITHUB_OUTPUT
echo "❌ Input assets validation failed"
fi
continue-on-error: true
- name: Comment on PR with validation results (failures only)
if: steps.validation.outputs.validation_failed == 'true'
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs');
const path = require('path');
// Read the validation report
const reportPath = path.join(process.env.GITHUB_WORKSPACE, 'asset_validation_report.md');
if (!fs.existsSync(reportPath)) {
console.log('No validation report found, skipping comment.');
return;
}
const report = fs.readFileSync(reportPath, 'utf8');
// Find existing comment
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const botComment = comments.find(comment =>
comment.user.type === 'Bot' &&
comment.body.includes('Input Assets Validation Report')
);
const commentBody = `${report}\n\n---\n*This comment is automatically generated by the Input Assets Validation workflow.*`;
if (botComment) {
// Update existing comment
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: commentBody
});
console.log('Updated existing comment');
} else {
// Create new comment
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: commentBody
});
console.log('Created new comment');
}
- name: Remove or update comment on successful validation
if: steps.validation.outputs.validation_failed != 'true'
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
// Find existing comment
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const botComment = comments.find(comment =>
comment.user.type === 'Bot' &&
comment.body.includes('Input Assets Validation Report')
);
if (botComment) {
// Delete the existing comment since validation passed
await github.rest.issues.deleteComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id
});
console.log('Deleted previous validation failure comment - validation now passes');
} else {
console.log('No previous comment found - validation passed cleanly');
}
- name: Upload validation report as artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: asset-validation-report
path: asset_validation_report.md
if-no-files-found: warn
- name: Fail workflow if validation failed
if: steps.validation.outputs.validation_failed == 'true'
run: |
echo "❌ Input Assets Validation failed. Please fix the issues before merging this PR."
echo "Check the PR comments and artifact for detailed error information."
exit 1