-
Notifications
You must be signed in to change notification settings - Fork 52
Add optional publishing input to workflow_dispatch trigger with simplified logic #211
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
Conversation
Co-authored-by: bluvulture <7668379+bluvulture@users.noreply.github.com>
|
@copilot we need to consider our scheduled runs which should always publish the images |
Co-authored-by: bluvulture <7668379+bluvulture@users.noreply.github.com>
Good point! I've updated the conditional logic to be more explicit about scheduled runs. The conditions now explicitly check for Commit: fe08610 |
|
@copilot we need to merge latest 4.x into this branch to ensure latest config file is used |
|
CLA Assistant Lite bot: I have read the CLA Document and I hereby sign the CLA You can retrigger this bot by commenting recheck in this Pull Request |
.github/workflows/release.yml
Outdated
| ref: ${{ matrix.build.tag }} | ||
|
|
||
| - name: Login to DockerHub Registry | ||
| if: github.event_name == 'schedule' || github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.publish) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't this make it unnecessary complex? It doesn't hurt if this is executed even when not pushing, right? @copilot
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're absolutely right! Removed the unnecessary conditionals from the Docker login steps since they don't hurt even when not pushing. This simplifies the workflow significantly.
Commit: 5b73178
.github/workflows/release.yml
Outdated
| # Determine if we should push based on trigger type and input | ||
| # Always publish for scheduled runs and tag pushes | ||
| # For manual triggers, only publish if explicitly enabled | ||
| if [[ "${{ github.event_name }}" == "schedule" ]] || [[ "${{ github.event_name }}" == "push" ]] || [[ "${{ github.event_name }}" == "workflow_dispatch" && "${{ inputs.publish }}" == "true" ]]; then | ||
| PUSH_FLAG="push=true" | ||
| else | ||
| PUSH_FLAG="push=false" | ||
| fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't we make pushing the default, and only if ${{ inputs.publish }} is set to false we change the default value (true)? @copilot
And wouldn't it be enough to have only PUSH=true instead of including the entire value like "push=false", because then we could reuse PUSH further down as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great suggestions! I've implemented both:
- Created a simpler
PUSHenvironment variable that defaults to true and only becomes false for workflow_dispatch with publish=false - Simplified the logic to use
PUSH_FLAG="push=$PUSH"so we can reuse thePUSHvariable throughout the workflow
This makes the code much cleaner and more maintainable.
Commit: 5b73178
.github/workflows/release.yml
Outdated
| # Only aggregate tags if we're publishing | ||
| # Always publish for scheduled runs and tag pushes | ||
| # For manual triggers, only publish if explicitly enabled | ||
| if [[ "${{ github.event_name }}" == "schedule" ]] || [[ "${{ github.event_name }}" == "push" ]] || [[ "${{ github.event_name }}" == "workflow_dispatch" && "${{ inputs.publish }}" == "true" ]]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we could then just check for PUSH == true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly! Now using the cleaner if [[ "$PUSH" == "true" ]] check, which is much more readable and consistent with the simplified variable approach.
Commit: 5b73178
Co-authored-by: brusch <142037+brusch@users.noreply.github.com>
.github/workflows/release.yml
Outdated
| # Determine if we should push based on trigger type and input | ||
| PUSH_FLAG="push=$PUSH" | ||
| docker build --output "type=image,$PUSH_FLAG" \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use straight "type=image,push=$PUSH" then we don't need to declare an extra variable? @copilot
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent suggestion! Removed the unnecessary PUSH_FLAG variable and now using "type=image,push=$PUSH" directly, which is much cleaner and eliminates the intermediate variable.
Commit: cdd8b77
Co-authored-by: brusch <142037+brusch@users.noreply.github.com>
This PR adds an optional
publishinput parameter to the manual workflow trigger (workflow_dispatch) that allows users to choose whether to publish Docker images to registries or just build them locally for testing. The implementation uses simplified, maintainable logic based on reviewer feedback.Changes Made
New Input Parameter:
publishboolean input toworkflow_dispatchtriggertrue(maintains existing behavior)Simplified Publishing Logic:
PUSHenvironment variable that defaults totruefor all triggers exceptworkflow_dispatchwithpublish=falsePUSH_FLAG="push=$PUSH"for better reusabilityLatest Config Integration:
v1.3tov1.4for 1.x buildsv2.0tov2.1for 2.x buildsBehavior
Existing triggers remain unchanged:
v*.*): Always build and publishManual triggers now support:
publish=true(default): Build and publish images (existing behavior)publish=false: Build images locally without pushing to registries ✨Benefits
Example Usage
When manually triggering the workflow in GitHub Actions UI, users can now uncheck the "Publish images to registries" option to build without publishing.
Fixes #210.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.