From 4bcfd157f5de44b1a85d6f3ed56195e6c3296996 Mon Sep 17 00:00:00 2001 From: m-Bilal Date: Tue, 22 Jul 2025 02:49:28 +0530 Subject: [PATCH 1/9] fix issue creation for ndc-nodejs-lambda auto version bump job --- .../workflows/auto-update-ndc-lambda-sdk.yaml | 37 +++++++++++++++++-- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/.github/workflows/auto-update-ndc-lambda-sdk.yaml b/.github/workflows/auto-update-ndc-lambda-sdk.yaml index b5685e8..1d5e204 100644 --- a/.github/workflows/auto-update-ndc-lambda-sdk.yaml +++ b/.github/workflows/auto-update-ndc-lambda-sdk.yaml @@ -12,6 +12,7 @@ jobs: permissions: contents: write pull-requests: write + issues: write env: RUNNING_IN_CI: "true" steps: @@ -186,7 +187,22 @@ jobs: - name: Create failure issue if: failure() + continue-on-error: true run: | + # Ensure GitHub CLI is available for issue creation + if ! command -v gh &> /dev/null; then + echo "❌ GitHub CLI not available - cannot create failure issue" + exit 1 + fi + + # Test GitHub CLI authentication + if ! gh auth status &> /dev/null; then + echo "❌ GitHub CLI not authenticated - cannot create failure issue" + exit 1 + fi + + echo "✅ GitHub CLI is available and authenticated" + # Get the workflow run URL WORKFLOW_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" @@ -229,14 +245,29 @@ jobs: EOF # Create the issue - gh issue create \ + echo "Creating failure issue..." + ISSUE_URL=$(gh issue create \ --title "🚨 Auto Update NDC Lambda SDK Workflow Failed - Run #${{ github.run_id }}" \ --body-file issue_description.md \ --assignee m-Bilal \ --label "bug" \ --label "automation" \ - --label "high-priority" + --label "high-priority" \ + --json url --jq '.url') - echo "✅ Failure issue created successfully!" + if [ $? -eq 0 ] && [ -n "$ISSUE_URL" ]; then + echo "✅ Failure issue created successfully: $ISSUE_URL" + else + echo "❌ Failed to create issue" + echo "Attempting to create issue without assignee..." + # Fallback: try without assignee in case user doesn't exist + gh issue create \ + --title "🚨 Auto Update NDC Lambda SDK Workflow Failed - Run #${{ github.run_id }}" \ + --body-file issue_description.md \ + --label "bug" \ + --label "automation" \ + --label "high-priority" + echo "✅ Fallback issue created (please assign manually)" + fi env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 9f4db88772e27356669a6441f3ac2aa66610cfb1 Mon Sep 17 00:00:00 2001 From: m-Bilal Date: Tue, 22 Jul 2025 02:53:42 +0530 Subject: [PATCH 2/9] fix --- .../workflows/auto-update-ndc-lambda-sdk.yaml | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/.github/workflows/auto-update-ndc-lambda-sdk.yaml b/.github/workflows/auto-update-ndc-lambda-sdk.yaml index 1d5e204..171426a 100644 --- a/.github/workflows/auto-update-ndc-lambda-sdk.yaml +++ b/.github/workflows/auto-update-ndc-lambda-sdk.yaml @@ -246,28 +246,29 @@ jobs: # Create the issue echo "Creating failure issue..." - ISSUE_URL=$(gh issue create \ + if gh issue create \ --title "🚨 Auto Update NDC Lambda SDK Workflow Failed - Run #${{ github.run_id }}" \ --body-file issue_description.md \ --assignee m-Bilal \ --label "bug" \ --label "automation" \ - --label "high-priority" \ - --json url --jq '.url') - - if [ $? -eq 0 ] && [ -n "$ISSUE_URL" ]; then - echo "✅ Failure issue created successfully: $ISSUE_URL" + --label "high-priority"; then + echo "✅ Failure issue created successfully!" else - echo "❌ Failed to create issue" + echo "❌ Failed to create issue with assignee" echo "Attempting to create issue without assignee..." - # Fallback: try without assignee in case user doesn't exist - gh issue create \ + # Fallback: try without assignee in case user doesn't exist or there are permission issues + if gh issue create \ --title "🚨 Auto Update NDC Lambda SDK Workflow Failed - Run #${{ github.run_id }}" \ --body-file issue_description.md \ --label "bug" \ --label "automation" \ - --label "high-priority" - echo "✅ Fallback issue created (please assign manually)" + --label "high-priority"; then + echo "✅ Fallback issue created successfully (please assign manually)" + else + echo "❌ Failed to create issue entirely" + exit 1 + fi fi env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} From e23cb92b4c57f1275539fab120861204c58915c2 Mon Sep 17 00:00:00 2001 From: m-Bilal Date: Tue, 22 Jul 2025 02:57:53 +0530 Subject: [PATCH 3/9] fix --- .../workflows/auto-update-ndc-lambda-sdk.yaml | 35 ++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/.github/workflows/auto-update-ndc-lambda-sdk.yaml b/.github/workflows/auto-update-ndc-lambda-sdk.yaml index 171426a..3b93f80 100644 --- a/.github/workflows/auto-update-ndc-lambda-sdk.yaml +++ b/.github/workflows/auto-update-ndc-lambda-sdk.yaml @@ -239,7 +239,7 @@ jobs: --- - @m-Bilal Please investigate this failure and fix the automated workflow. + **@m-Bilal** Please investigate this failure and fix the automated workflow. *This issue was automatically created by the failed Auto Update NDC Lambda SDK workflow.* EOF @@ -255,7 +255,7 @@ jobs: --label "high-priority"; then echo "✅ Failure issue created successfully!" else - echo "❌ Failed to create issue with assignee" + echo "❌ Failed to create issue with assignee and labels" echo "Attempting to create issue without assignee..." # Fallback: try without assignee in case user doesn't exist or there are permission issues if gh issue create \ @@ -266,8 +266,35 @@ jobs: --label "high-priority"; then echo "✅ Fallback issue created successfully (please assign manually)" else - echo "❌ Failed to create issue entirely" - exit 1 + echo "❌ Failed to create issue with labels, trying without labels..." + # Final fallback: try without labels in case they don't exist + if gh issue create \ + --title "🚨 Auto Update NDC Lambda SDK Workflow Failed - Run #${{ github.run_id }}" \ + --body-file issue_description.md \ + --assignee m-Bilal; then + echo "✅ Issue created without labels (please add labels manually)" + else + echo "❌ Failed to create issue with assignee, trying minimal issue..." + # Create a simple fallback description that ensures you're tagged + cat > fallback_issue_description.md << EOF + 🚨 **Auto Update NDC Lambda SDK Workflow Failed** + + The automated workflow failed. Please check the logs: + https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} + + **@m-Bilal** Please investigate this failure. + EOF + + # Ultimate fallback: just title and simple body with mention + if gh issue create \ + --title "🚨 Auto Update NDC Lambda SDK Workflow Failed - Run #${{ github.run_id }}" \ + --body-file fallback_issue_description.md; then + echo "✅ Minimal issue created successfully (please assign and label manually)" + else + echo "❌ Failed to create issue entirely" + exit 1 + fi + fi fi fi env: From 6da1abee5081604f8b812c5bdaaf4bd25ce6ffa1 Mon Sep 17 00:00:00 2001 From: m-Bilal Date: Tue, 22 Jul 2025 03:04:02 +0530 Subject: [PATCH 4/9] fix --- .../workflows/auto-update-ndc-lambda-sdk.yaml | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/.github/workflows/auto-update-ndc-lambda-sdk.yaml b/.github/workflows/auto-update-ndc-lambda-sdk.yaml index 3b93f80..cd76eb8 100644 --- a/.github/workflows/auto-update-ndc-lambda-sdk.yaml +++ b/.github/workflows/auto-update-ndc-lambda-sdk.yaml @@ -68,9 +68,10 @@ jobs: run: | LATEST="${{ steps.latest-release.outputs.latest-version }}" PR_TITLE="chore: update NDC Lambda SDK to $LATEST" - - # Check if PR already exists - EXISTING_PR=$(gh pr list --state open --search "in:title \"update NDC Lambda SDK to $LATEST\"" --json number --jq '.[0].number // empty') + BRANCH_NAME="github-ci/update-ndc-lambda-sdk-$LATEST" + + # Check if PR already exists (check by branch name for more accuracy) + EXISTING_PR=$(gh pr list --state open --head "$BRANCH_NAME" --json number --jq '.[0].number // empty' 2>/dev/null || echo "") if [ -n "$EXISTING_PR" ]; then echo "pr-exists=true" >> $GITHUB_OUTPUT @@ -100,28 +101,29 @@ jobs: if: steps.compare.outputs.needs-update == 'true' && steps.check-pr.outputs.pr-exists == 'false' run: | LATEST="${{ steps.latest-release.outputs.latest-version }}" - BRANCH_NAME="auto-update/ndc-lambda-sdk-$LATEST" - + # Use github-ci/ prefix for branch name + BRANCH_NAME="github-ci/update-ndc-lambda-sdk-$LATEST" + # Configure git git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" - + # Create and switch to new branch git checkout -b "$BRANCH_NAME" - + # Update context.ts sed -i "s/const NDC_NODEJS_LAMBDA_SDK_VERSION = \".*\";/const NDC_NODEJS_LAMBDA_SDK_VERSION = \"$LATEST\";/" src/app/context.ts - + # Update Dockerfile sed -i "s|FROM ghcr.io/hasura/ndc-nodejs-lambda:.*|FROM ghcr.io/hasura/ndc-nodejs-lambda:$LATEST|" connector-definition/.hasura-connector/Dockerfile - + # Commit changes git add src/app/context.ts connector-definition/.hasura-connector/Dockerfile git commit -m "chore: update NDC Lambda SDK to $LATEST" - - # Push branch - git push origin "$BRANCH_NAME" - + + # Force push branch (in case it exists from a previous run) + git push --force-with-lease origin "$BRANCH_NAME" + echo "branch-name=$BRANCH_NAME" >> $GITHUB_OUTPUT env: GITHUB_OUTPUT: ${{ github.output }} @@ -131,7 +133,7 @@ jobs: run: | LATEST="${{ steps.latest-release.outputs.latest-version }}" CURRENT="${{ steps.current-version.outputs.current-version }}" - BRANCH_NAME="auto-update/ndc-lambda-sdk-$LATEST" + BRANCH_NAME="github-ci/update-ndc-lambda-sdk-$LATEST" # Create PR description cat > pr_description.md << EOF From 73da899b900fece3ba236ab5e9b258d3daac7c1b Mon Sep 17 00:00:00 2001 From: m-Bilal Date: Tue, 22 Jul 2025 03:06:55 +0530 Subject: [PATCH 5/9] fix --- .github/workflows/auto-update-ndc-lambda-sdk.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/auto-update-ndc-lambda-sdk.yaml b/.github/workflows/auto-update-ndc-lambda-sdk.yaml index cd76eb8..27ce0e5 100644 --- a/.github/workflows/auto-update-ndc-lambda-sdk.yaml +++ b/.github/workflows/auto-update-ndc-lambda-sdk.yaml @@ -170,7 +170,6 @@ jobs: --head "$BRANCH_NAME" \ --base main \ --reviewer m-Bilal \ - --label "dependencies" \ --label "automated" echo "✅ Pull Request created successfully!" From 63357245708d46ec84624f5008e9b8663ed5c2aa Mon Sep 17 00:00:00 2001 From: m-Bilal Date: Tue, 22 Jul 2025 03:09:36 +0530 Subject: [PATCH 6/9] fix --- .github/workflows/auto-update-ndc-lambda-sdk.yaml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/auto-update-ndc-lambda-sdk.yaml b/.github/workflows/auto-update-ndc-lambda-sdk.yaml index 27ce0e5..03e1aa1 100644 --- a/.github/workflows/auto-update-ndc-lambda-sdk.yaml +++ b/.github/workflows/auto-update-ndc-lambda-sdk.yaml @@ -108,6 +108,9 @@ jobs: git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" + # Delete the branch if it exists remotely to avoid conflicts + git push origin --delete "$BRANCH_NAME" 2>/dev/null || echo "Branch doesn't exist remotely, continuing..." + # Create and switch to new branch git checkout -b "$BRANCH_NAME" @@ -121,8 +124,8 @@ jobs: git add src/app/context.ts connector-definition/.hasura-connector/Dockerfile git commit -m "chore: update NDC Lambda SDK to $LATEST" - # Force push branch (in case it exists from a previous run) - git push --force-with-lease origin "$BRANCH_NAME" + # Push the new branch + git push origin "$BRANCH_NAME" echo "branch-name=$BRANCH_NAME" >> $GITHUB_OUTPUT env: From aee77fde0384aa4bbcb8072b0fc1b4e97deb460b Mon Sep 17 00:00:00 2001 From: m-Bilal Date: Tue, 22 Jul 2025 03:12:32 +0530 Subject: [PATCH 7/9] fix --- .github/workflows/auto-update-ndc-lambda-sdk.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/auto-update-ndc-lambda-sdk.yaml b/.github/workflows/auto-update-ndc-lambda-sdk.yaml index 03e1aa1..126e49b 100644 --- a/.github/workflows/auto-update-ndc-lambda-sdk.yaml +++ b/.github/workflows/auto-update-ndc-lambda-sdk.yaml @@ -173,7 +173,7 @@ jobs: --head "$BRANCH_NAME" \ --base main \ --reviewer m-Bilal \ - --label "automated" + --label "automation" echo "✅ Pull Request created successfully!" env: From e763f0b9b0c040aca0eabdec4e3003b1506bc7b5 Mon Sep 17 00:00:00 2001 From: m-Bilal Date: Tue, 22 Jul 2025 03:17:16 +0530 Subject: [PATCH 8/9] fix --- .../workflows/auto-update-ndc-lambda-sdk.yaml | 41 ++++++++++++++++++- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/.github/workflows/auto-update-ndc-lambda-sdk.yaml b/.github/workflows/auto-update-ndc-lambda-sdk.yaml index 126e49b..29abc96 100644 --- a/.github/workflows/auto-update-ndc-lambda-sdk.yaml +++ b/.github/workflows/auto-update-ndc-lambda-sdk.yaml @@ -37,14 +37,36 @@ jobs: - name: Get current version from context.ts id: current-version run: | + echo "Debugging: Looking for version in context.ts" + grep -n "NDC_NODEJS_LAMBDA_SDK_VERSION" src/app/context.ts || echo "Pattern not found" + CURRENT_VERSION=$(grep -E "const NDC_NODEJS_LAMBDA_SDK_VERSION = " src/app/context.ts | sed -E 's/.*"([^"]+)".*/\1/') + + if [ -z "$CURRENT_VERSION" ]; then + echo "❌ Failed to extract current version from context.ts" + echo "File content around the version:" + grep -A2 -B2 "NDC_NODEJS_LAMBDA_SDK_VERSION" src/app/context.ts || echo "No matches found" + exit 1 + fi + echo "current-version=$CURRENT_VERSION" >> $GITHUB_OUTPUT echo "Current version in context.ts: $CURRENT_VERSION" - name: Get latest release from GitHub API id: latest-release run: | - LATEST_RELEASE=$(curl -s https://api.github.com/repos/hasura/ndc-nodejs-lambda/releases/latest | jq -r '.tag_name') + echo "Debugging: Fetching latest release from GitHub API" + API_RESPONSE=$(curl -s https://api.github.com/repos/hasura/ndc-nodejs-lambda/releases/latest) + echo "API Response: $API_RESPONSE" + + LATEST_RELEASE=$(echo "$API_RESPONSE" | jq -r '.tag_name') + + if [ -z "$LATEST_RELEASE" ] || [ "$LATEST_RELEASE" = "null" ]; then + echo "❌ Failed to extract latest release version" + echo "API Response was: $API_RESPONSE" + exit 1 + fi + echo "latest-version=$LATEST_RELEASE" >> $GITHUB_OUTPUT echo "Latest release: $LATEST_RELEASE" @@ -53,7 +75,22 @@ jobs: run: | CURRENT="${{ steps.current-version.outputs.current-version }}" LATEST="${{ steps.latest-release.outputs.latest-version }}" - + + echo "Debugging version comparison:" + echo "CURRENT: '$CURRENT'" + echo "LATEST: '$LATEST'" + + # Validate that we have non-empty versions + if [ -z "$CURRENT" ] || [ "$CURRENT" = "null" ]; then + echo "❌ Current version is empty or null" + exit 1 + fi + + if [ -z "$LATEST" ] || [ "$LATEST" = "null" ]; then + echo "❌ Latest version is empty or null" + exit 1 + fi + if [ "$CURRENT" = "$LATEST" ]; then echo "needs-update=false" >> $GITHUB_OUTPUT echo "✅ Already up to date: $CURRENT" From 93fdd34e879da59883d0c24ebcd0e9954c3fa70d Mon Sep 17 00:00:00 2001 From: m-Bilal Date: Tue, 22 Jul 2025 03:22:03 +0530 Subject: [PATCH 9/9] fix --- .../workflows/auto-update-ndc-lambda-sdk.yaml | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/.github/workflows/auto-update-ndc-lambda-sdk.yaml b/.github/workflows/auto-update-ndc-lambda-sdk.yaml index 29abc96..d8992a3 100644 --- a/.github/workflows/auto-update-ndc-lambda-sdk.yaml +++ b/.github/workflows/auto-update-ndc-lambda-sdk.yaml @@ -169,6 +169,7 @@ jobs: GITHUB_OUTPUT: ${{ github.output }} - name: Create Pull Request + id: create-pr if: steps.compare.outputs.needs-update == 'true' && steps.check-pr.outputs.pr-exists == 'false' run: | LATEST="${{ steps.latest-release.outputs.latest-version }}" @@ -213,6 +214,78 @@ jobs: --label "automation" echo "✅ Pull Request created successfully!" + + # Get the PR URL and number for changelog + PR_INFO=$(gh pr view "$BRANCH_NAME" --json url,number) + PR_URL=$(echo "$PR_INFO" | jq -r '.url') + PR_NUMBER=$(echo "$PR_INFO" | jq -r '.number') + echo "PR URL: $PR_URL" + echo "PR Number: $PR_NUMBER" + echo "pr-url=$PR_URL" >> $GITHUB_OUTPUT + echo "pr-number=$PR_NUMBER" >> $GITHUB_OUTPUT + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Update changelog + if: steps.compare.outputs.needs-update == 'true' && steps.check-pr.outputs.pr-exists == 'false' + run: | + LATEST="${{ steps.latest-release.outputs.latest-version }}" + CURRENT="${{ steps.current-version.outputs.current-version }}" + BRANCH_NAME="github-ci/update-ndc-lambda-sdk-$LATEST" + PR_URL="${{ steps.create-pr.outputs.pr-url }}" + PR_NUMBER="${{ steps.create-pr.outputs.pr-number }}" + + # Get current date + CURRENT_DATE=$(date '+%Y-%m-%d') + + # Create changelog entry matching existing format + CHANGELOG_ENTRY="- Update NDC NodeJS Lambda to \`$LATEST\` ([#$PR_NUMBER]($PR_URL))" + + # Check if changelog.md exists + if [ ! -f "changelog.md" ]; then + echo "❌ changelog.md not found" + exit 1 + fi + + # Create a temporary file with the new entry + echo "" > temp_entry.txt + echo "$CHANGELOG_ENTRY" >> temp_entry.txt + + # Find the "## Unreleased" section and add the entry + if grep -q "## Unreleased" changelog.md; then + # Find line number of "## Unreleased" and insert after it + LINE_NUM=$(grep -n "## Unreleased" changelog.md | head -1 | cut -d: -f1) + NEXT_LINE=$((LINE_NUM + 1)) + + # Split file and insert entry + head -n $LINE_NUM changelog.md > changelog_temp.md + cat temp_entry.txt >> changelog_temp.md + tail -n +$NEXT_LINE changelog.md >> changelog_temp.md + mv changelog_temp.md changelog.md + echo "✅ Added changelog entry: $CHANGELOG_ENTRY" + else + # If no "## Unreleased" section, add it at the top + echo "Adding new Unreleased section to changelog.md" + echo "# Changelog" > changelog_temp.md + echo "" >> changelog_temp.md + echo "## Unreleased" >> changelog_temp.md + echo "" >> changelog_temp.md + echo "$CHANGELOG_ENTRY" >> changelog_temp.md + echo "" >> changelog_temp.md + cat changelog.md >> changelog_temp.md + mv changelog_temp.md changelog.md + echo "✅ Created Unreleased section and added entry" + fi + + # Clean up temp file + rm -f temp_entry.txt + + # Commit and push the changelog update + git add changelog.md + git commit -m "docs: add changelog entry for NDC Lambda SDK $LATEST update" + git push origin "$BRANCH_NAME" + + echo "✅ Changelog updated and pushed to PR branch" env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}