Skip to content

Further Debugging of Review App Deployment Workflow #636

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 3 commits into from
Apr 9, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
85 changes: 75 additions & 10 deletions .github/workflows/deploy-to-control-plane-review-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,6 @@ jobs:
contains(github.event.comment.body, '/deploy-review-app'))
runs-on: ubuntu-latest
steps:
# Initial checkout only for pull_request and push events
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.sha }}

- name: Validate Required Secrets and Variables
shell: bash
Expand All @@ -72,6 +66,77 @@ jobs:
exit 1
fi

- name: Get PR HEAD Ref
id: getRef
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# For push events, try to find associated PR first
if [[ "${{ github.event_name }}" == "push" ]]; then
PR_DATA=$(gh pr list --head "${{ github.ref_name }}" --json number,headRefName,headRefOid --jq '.[0]')
if [[ -n "$PR_DATA" ]]; then
PR_NUMBER=$(echo "$PR_DATA" | jq -r .number)
else
echo "No PR found for branch ${{ github.ref_name }}, skipping deployment"
echo "DO_DEPLOY=false" >> $GITHUB_ENV
exit 0
fi
else
# Get PR number based on event type
case "${{ github.event_name }}" in
"workflow_dispatch")
PR_NUMBER="${{ github.event.inputs.pr_number }}"
;;
"issue_comment")
PR_NUMBER="${{ github.event.issue.number }}"
;;
"pull_request")
PR_NUMBER="${{ github.event.pull_request.number }}"
;;
*)
echo "Error: Unsupported event type ${{ github.event_name }}"
exit 1
;;
esac
fi

if [[ -z "$PR_NUMBER" ]]; then
echo "Error: Could not determine PR number"
echo "Event type: ${{ github.event_name }}"
echo "Event action: ${{ github.event.action }}"
echo "Ref name: ${{ github.ref_name }}"
echo "Available event data:"
echo "- PR number from inputs: ${{ github.event.inputs.pr_number }}"
echo "- PR number from issue: ${{ github.event.issue.number }}"
echo "- PR number from pull_request: ${{ github.event.pull_request.number }}"
exit 1
fi

# Get PR data
if [[ -z "$PR_DATA" ]]; then
PR_DATA=$(gh pr view "$PR_NUMBER" --json headRefName,headRefOid)
if [[ -z "$PR_DATA" ]]; then
echo "Error: PR DATA for PR #$PR_NUMBER not found"
echo "Event type: ${{ github.event_name }}"
echo "Event action: ${{ github.event.action }}"
echo "Ref name: ${{ github.ref_name }}"
echo "Attempted to fetch PR data with: gh pr view $PR_NUMBER"
exit 1
fi
fi

# Extract and set PR data
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
echo "APP_NAME=${{ vars.REVIEW_APP_PREFIX }}-$PR_NUMBER" >> $GITHUB_ENV
echo "PR_REF=$(echo $PR_DATA | jq -r .headRefName)" >> $GITHUB_OUTPUT
echo "PR_SHA=$(echo $PR_DATA | jq -r .headRefOid)" >> $GITHUB_ENV

- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ env.PR_SHA }}

- name: Setup Environment
uses: ./.github/actions/setup-environment
with:
Expand Down Expand Up @@ -228,7 +293,7 @@ jobs:
with:
script: |
const buildingMessage = [
'🏗️ Building Docker image for PR #${{ env.PR_NUMBER }}, commit ${{ github.sha }}',
'🏗️ Building Docker image for PR #${{ env.PR_NUMBER }}, commit ${{ env.PR_SHA }}',
'',
'📝 [View Build Logs](${{ env.WORKFLOW_URL }})',
'',
Expand All @@ -248,7 +313,7 @@ jobs:
with:
app_name: ${{ env.APP_NAME }}
org: ${{ vars.CPLN_ORG_STAGING }}
commit: ${{ github.sha }}
commit: ${{ env.PR_SHA }}
PR_NUMBER: ${{ env.PR_NUMBER }}

- name: Update Status - Deploying
Expand Down Expand Up @@ -307,7 +372,7 @@ jobs:

// Define messages based on deployment status
const successMessage = [
'✅ Deployment complete for PR #' + prNumber + ', commit ' + '${{ github.sha }}',
'✅ Deployment complete for PR #' + prNumber + ', commit ' + '${{ env.PR_SHA }}',
'',
'🚀 [Review App for PR #' + prNumber + '](' + appUrl + ')',
consoleLink,
Expand All @@ -316,7 +381,7 @@ jobs:
].join('\n');

const failureMessage = [
'❌ Deployment failed for PR #' + prNumber + ', commit ' + '${{ github.sha }}',
'❌ Deployment failed for PR #' + prNumber + ', commit ' + '${{ env.PR_SHA }}',
'',
consoleLink,
'',
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 @@ -12,7 +12,7 @@ export default class Footer extends BaseComponent {
Example of styling using image-url and Open Sans Light custom font
</h3>
</a>
<a href="https://x.com/railsonmaui" className="flex gap-4 items-center">
<a href="https://twitter.com/railsonmaui" className="flex gap-4 items-center">
<div className="w-16 h-16 bg-[url('../images/twitter_64.png')]" />
Rails On Maui on Twitter
</a>
Expand Down
2 changes: 1 addition & 1 deletion config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ default: &default

development:
<<: *default
database: react-webpack-rails-tutorial-development
database: react-webpack-rails-tutoria-developmentl
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Typographical Error in Development Database Name.
The database name "react-webpack-rails-tutoria-developmentl" in the development section appears to contain a typo. It likely should be "react-webpack-rails-tutorial-development". This error could prevent a proper connection in the development environment.


# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
Expand Down
Loading