Skip to content
Closed
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
88 changes: 88 additions & 0 deletions .github/workflows/trigger-lightning-node-e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Trigger Lightning Node E2E Tests

on:
pull_request:
types: [opened, synchronize, reopened]

permissions:
contents: read
# Need write permission to create status checks (optional)
pull-requests: write

jobs:
trigger-e2e:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Verify token access to lightning-node repository
env:
LIGHTNING_NODE_REPO: ${{ vars.LIGHTNING_NODE_REPO || 'CumuloGlobal/lightning-node' }}
TOKEN: ${{ secrets.LIGHTNING_NODE_DISPATCH_TOKEN || secrets.GITHUB_TOKEN }}
run: |
REPO_OWNER=$(echo "$LIGHTNING_NODE_REPO" | cut -d'/' -f1)
REPO_NAME=$(echo "$LIGHTNING_NODE_REPO" | cut -d'/' -f2)

echo "Verifying access to repository: $LIGHTNING_NODE_REPO"

# Test if we can access the repository
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" \
-H "Authorization: token $TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/$LIGHTNING_NODE_REPO")

if [ "$HTTP_CODE" = "200" ]; then
echo "✅ Successfully verified access to $LIGHTNING_NODE_REPO"
elif [ "$HTTP_CODE" = "404" ]; then
echo "❌ Repository not found: $LIGHTNING_NODE_REPO"
echo "Please verify:"
echo " 1. The repository name is correct"
echo " 2. The token has access to this private repository"
echo " 3. The token owner is a member of the '$REPO_OWNER' organization"
exit 1
elif [ "$HTTP_CODE" = "403" ]; then
echo "❌ Access forbidden. The token may not have sufficient permissions."
echo "Please verify:"
echo " 1. The token has 'repo' scope (for private repos)"
echo " 2. The token owner has access to the '$REPO_OWNER' organization"
echo " 3. The repository allows access from external tokens"
exit 1
else
echo "❌ Unexpected error (HTTP $HTTP_CODE) when accessing $LIGHTNING_NODE_REPO"
exit 1
fi

- name: Trigger Lightning Node E2E Tests
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.LIGHTNING_NODE_DISPATCH_TOKEN || secrets.GITHUB_TOKEN }}
repository: ${{ vars.LIGHTNING_NODE_REPO || 'cumuloglobal/lightning-node' }}
event-type: mdk-checkout-pr
Comment on lines +58 to +61
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Guard dispatch when PAT is unavailable

If LIGHTNING_NODE_DISPATCH_TOKEN is not set (including all fork PRs, where secrets are unavailable), this step falls back to GITHUB_TOKEN but still targets the external cumuloglobal/lightning-node repo. GITHUB_TOKEN cannot dispatch events to another repository, so the repository-dispatch call will 401/403 and the E2E run never starts even though the workflow continues. Consider gating this step to non-fork PRs or requiring the PAT before dispatching to avoid silently skipping external E2E.

Useful? React with 👍 / 👎.

Comment on lines +58 to +61
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Guard dispatch when PAT is unavailable

If LIGHTNING_NODE_DISPATCH_TOKEN is not set (including all fork PRs, where secrets are unavailable), this step falls back to GITHUB_TOKEN but still targets the external cumuloglobal/lightning-node repo. GITHUB_TOKEN cannot dispatch events to another repository, so the repository-dispatch call will 401/403 and the E2E run never starts even though the workflow continues. Consider gating this step to non-fork PRs or requiring the PAT before dispatching to avoid silently skipping external E2E.

Useful? React with 👍 / 👎.

client-payload: |
{
"sha": "${{ github.event.pull_request.head.sha }}",
"ref": "${{ github.event.pull_request.head.ref }}",
"pr_number": ${{ github.event.pull_request.number }},
"pr_url": "${{ github.event.pull_request.html_url }}",
"repo": "${{ github.repository }}"
}

- name: Comment on PR
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const lightningNodeRepo = '${{ vars.LIGHTNING_NODE_REPO || 'cumuloglobal/lightning-node' }}';
const comment = `🔗 Lightning Node E2E tests have been triggered for this PR.

View the workflow run: https://github.com/${lightningNodeRepo}/actions/workflows/external-e2e.yml

The tests will build packages from this PR branch and run integration tests against the Lightning Node infrastructure.`;

github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});
Loading