Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jul 28, 2025

This PR adds an optional publish input 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:

  • Added publish boolean input to workflow_dispatch trigger
  • Default value: true (maintains existing behavior)
  • Description: "Publish images to registries"

Simplified Publishing Logic:

  • Created clean PUSH environment variable that defaults to true for all triggers except workflow_dispatch with publish=false
  • Removed unnecessary conditional logic from Docker login steps (they don't hurt even when not pushing)
  • Simplified push flag determination using PUSH_FLAG="push=$PUSH" for better reusability
  • Streamlined conditional checks throughout workflow for better maintainability

Latest Config Integration:

  • Merged latest 4.x branch to include updated tag versions:
    • Updated from v1.3 to v1.4 for 1.x builds
    • Updated from v2.0 to v2.1 for 2.x builds

Behavior

Existing triggers remain unchanged:

  • Tag pushes (v*.*): Always build and publish
  • Scheduled runs: Always build and publish

Manual triggers now support:

  • publish=true (default): Build and publish images (existing behavior)
  • publish=false: Build images locally without pushing to registries ✨

Benefits

  • Clean, maintainable code with simplified logic
  • Allows developers to test image builds without polluting registries
  • Maintains complete backward compatibility
  • Saves CI resources and registry storage for testing builds
  • No impact on production workflows

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.

Co-authored-by: bluvulture <7668379+bluvulture@users.noreply.github.com>
Copilot AI changed the title [WIP] Make publishing optional via input Add optional publishing input to workflow_dispatch trigger Jul 28, 2025
Copilot AI requested a review from bluvulture July 28, 2025 14:47
@bluvulture
Copy link
Contributor

@copilot we need to consider our scheduled runs which should always publish the images

Co-authored-by: bluvulture <7668379+bluvulture@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jul 28, 2025

@copilot we need to consider our scheduled runs which should always publish the images

Good point! I've updated the conditional logic to be more explicit about scheduled runs. The conditions now explicitly check for github.event_name == 'schedule' to ensure scheduled runs always publish images, making the behavior clearer and more maintainable.

Commit: fe08610

@bluvulture
Copy link
Contributor

@copilot we need to merge latest 4.x into this branch to ensure latest config file is used

Copy link
Contributor Author

Copilot AI commented Jul 30, 2025

@copilot we need to merge latest 4.x into this branch to ensure latest config file is used

Merged latest 4.x branch to get updated tag versions (v1.4, v2.1) while preserving the publishing logic changes.

Commit: 7058f79

Copilot AI changed the title Add optional publishing input to workflow_dispatch trigger Add optional publishing input to workflow_dispatch trigger with latest 4.x config Jul 30, 2025
@bluvulture bluvulture marked this pull request as ready for review July 30, 2025 07:41
@bluvulture bluvulture requested a review from brusch July 30, 2025 07:41
@github-actions
Copy link

CLA Assistant Lite bot:
Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request

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)
Copy link
Member

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

Copy link
Contributor Author

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

Comment on lines 122 to 129
# 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
Copy link
Member

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.

Copy link
Contributor Author

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:

  1. Created a simpler PUSH environment variable that defaults to true and only becomes false for workflow_dispatch with publish=false
  2. Simplified the logic to use PUSH_FLAG="push=$PUSH" so we can reuse the PUSH variable throughout the workflow

This makes the code much cleaner and more maintainable.

Commit: 5b73178

# 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
Copy link
Member

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

Copy link
Contributor Author

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>
Copilot AI changed the title Add optional publishing input to workflow_dispatch trigger with latest 4.x config Add optional publishing input to workflow_dispatch trigger with simplified logic Jul 30, 2025
Copilot AI requested a review from brusch July 30, 2025 08:28
# Determine if we should push based on trigger type and input
PUSH_FLAG="push=$PUSH"
docker build --output "type=image,$PUSH_FLAG" \
Copy link
Member

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

Copy link
Contributor Author

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>
Copilot AI requested a review from brusch July 30, 2025 09:09
@bluvulture bluvulture merged commit 3bc79a1 into 4.x Jul 31, 2025
2 of 3 checks passed
@bluvulture bluvulture deleted the copilot/fix-210 branch July 31, 2025 06:29
@github-actions github-actions bot locked and limited conversation to collaborators Jul 31, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make publishing optional via input

3 participants