Skip to content

Testing that Review App Deployment Workflow only redeploys on Pull Request Trigger #645

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
merged 9 commits into from
May 1, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .github/workflows/deploy-to-control-plane-review-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,11 @@ jobs:
fi
# Check if app exists and save state
if ! cpflow exists -a ${{ env.APP_NAME }}; then
if cpflow exists -a ${{ env.APP_NAME }}; then
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
exit 0
echo "Canceling job as review app has not been previously deployed."; sleep inf
fi
echo "APP_EXISTS=false" >> $GITHUB_ENV
else
echo "APP_EXISTS=true" >> $GITHUB_ENV
fi
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Incorrect APP_EXISTS flag handling & invalid sleep invocation.

  • The script currently sets APP_EXISTS=false when the app exists, which inverts the intended semantics for the “Setup Control Plane App if Not Existing” step. There’s also no branch for when the app does not exist, so APP_EXISTS remains undefined in that case.
  • Using sleep inf is invalid as the sleep command does not accept “inf” and will error instead of pausing indefinitely. To gracefully skip further deployment steps on PRs, use exit 0 (or a proper infinite loop) after setting the flag.

Apply this diff to correct the existence check and early-exit behavior:

-          if cpflow exists -a ${{ env.APP_NAME }}; then
-            if [[ "${{ github.event_name }}" == "pull_request" ]]; then
-              echo "Canceling job as review app has not been previously deployed."; sleep inf
-            fi
-            echo "APP_EXISTS=false" >> $GITHUB_ENV
-          fi
+          if cpflow exists -a ${{ env.APP_NAME }}; then
+            # App already exists
+            echo "APP_EXISTS=true" >> $GITHUB_ENV
+            if [[ "${{ github.event_name }}" == "pull_request" ]]; then
+              echo "Review app for PR #${{ env.PR_NUMBER }} already deployed; skipping redeployment."
+              exit 0
+            fi
+          else
+            # App does not exist
+            echo "APP_EXISTS=false" >> $GITHUB_ENV
+          fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if cpflow exists -a ${{ env.APP_NAME }}; then
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
exit 0
echo "Canceling job as review app has not been previously deployed."; sleep inf
fi
echo "APP_EXISTS=false" >> $GITHUB_ENV
else
echo "APP_EXISTS=true" >> $GITHUB_ENV
fi
if cpflow exists -a ${{ env.APP_NAME }}; then
# App already exists
echo "APP_EXISTS=true" >> $GITHUB_ENV
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
echo "Review app for PR #${{ env.PR_NUMBER }} already deployed; skipping redeployment."
exit 0
fi
else
# App does not exist
echo "APP_EXISTS=false" >> $GITHUB_ENV
fi

- name: Validate Deployment Request
Expand Down
2 changes: 1 addition & 1 deletion client/app/bundles/comments/components/Footer/Footer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default class Footer extends BaseComponent {
</a>
<a href="https://x.com/railsonmaui" className="flex gap-4 items-center">
<div className="w-16 h-16 bg-[url('../images/twitter_64.png')]" />
Rails On Maui on X
Rails On Maui on Twitter
</a>
</div>
</footer>
Expand Down
Loading