-
-
Notifications
You must be signed in to change notification settings - Fork 629
ci: Add workflow to regenerate static assets #1457
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
TwiN
merged 7 commits into
TwiN:master
from
PythonGermany:add-workflow-to-regenerate-static-assets
Dec 22, 2025
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
19a80f4
feat(ci): Add workflow to regenerate static assets
PythonGermany e238cc8
feat(ci): Use command action handle command triger
PythonGermany 9ca7382
fix(ci): Only give success response after commiting
PythonGermany d8e8ac5
fix(ci): Only run for pr comments
PythonGermany 6f695a5
refactor: Update command trigger text
PythonGermany 896f897
refactor: Explicitly list permission levels allowed
PythonGermany 936df01
chore(ci): Allow regenerate command on draft prs
PythonGermany File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| name: regenerate-static-assets | ||
| on: | ||
| issue_comment: | ||
| types: [created] | ||
|
|
||
| jobs: | ||
| check-command: | ||
| runs-on: ubuntu-latest | ||
| if: ${{ github.event.issue.pull_request }} | ||
| permissions: | ||
| pull-requests: write # required for adding reactions to command comments on PRs | ||
| checks: read | ||
| outputs: | ||
| continue: ${{ steps.command.outputs.continue }} | ||
| steps: | ||
| - name: Check command trigger | ||
| id: command | ||
| uses: github/command@v2 | ||
| with: | ||
| command: .regen-static-assets | ||
| allow_forks: true | ||
| skip_ci: true | ||
| skip_completing: true | ||
|
|
||
| regenerate-static-assets: | ||
| runs-on: ubuntu-latest | ||
| needs: check-command | ||
| if: ${{ needs.check-command.outputs.continue == 'true' }} | ||
PythonGermany marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| permissions: | ||
| contents: write | ||
| outputs: | ||
| status: ${{ steps.commit.outputs.status }} | ||
| steps: | ||
| - name: Get PR branch | ||
| id: pr | ||
| uses: actions/github-script@v8 | ||
| with: | ||
| script: | | ||
| const pr = await github.rest.pulls.get({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| pull_number: context.issue.number | ||
| }); | ||
| core.setOutput('ref', pr.data.head.ref); | ||
| core.setOutput('repo', pr.data.head.repo.full_name); | ||
| - name: Checkout PR branch | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| repository: ${{ steps.pr.outputs.repo }} | ||
| ref: ${{ steps.pr.outputs.ref }} | ||
| - name: Regenerate static assets | ||
| run: | | ||
| make frontend-install-dependencies | ||
| make frontend-build | ||
| - name: Commit and push changes | ||
| id: commit | ||
| run: | | ||
| echo "Checking for changes..." | ||
| if git diff --quiet; then | ||
| echo "No changes detected." | ||
| echo "status=no_changes" >> $GITHUB_OUTPUT | ||
| exit 0 | ||
| fi | ||
| git config --global user.name "github-actions[bot]" | ||
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | ||
| echo "Changes detected. Committing and pushing..." | ||
| git add . | ||
| git commit -m "chore(ui): Regenerate static assets" | ||
| git push origin ${{ steps.pr.outputs.ref }} | ||
| echo "status=success" >> $GITHUB_OUTPUT | ||
|
|
||
| create-response-comment: | ||
| runs-on: ubuntu-latest | ||
| needs: [check-command, regenerate-static-assets] | ||
| if: ${{ !cancelled() && needs.check-command.outputs.continue == 'true' }} | ||
| permissions: | ||
| pull-requests: write | ||
| steps: | ||
| - name: Create response comment | ||
| uses: actions/github-script@v8 | ||
| with: | ||
| script: | | ||
| const status = '${{ needs.regenerate-static-assets.outputs.status }}'; | ||
| let reaction = ''; | ||
| if (status === 'success') { | ||
| reaction = 'hooray'; | ||
| } else if (status === 'no_changes') { | ||
| reaction = '+1'; | ||
| } else { | ||
| reaction = '-1'; | ||
| var workflowUrl = `${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}`; | ||
| var body = '⚠️ There was an issue regenerating static assets. Please check the [workflow run logs](' + workflowUrl + ') for more details.'; | ||
| await github.rest.issues.createComment({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: context.issue.number, | ||
| body: body | ||
| }); | ||
| } | ||
| await github.rest.reactions.createForIssueComment({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| comment_id: context.payload.comment.id, | ||
| content: reaction | ||
| }); | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.