|
| 1 | +name: Trigger Devin for New Chain Request Validation |
| 2 | + |
| 3 | +on: |
| 4 | + issues: |
| 5 | + types: [labeled] |
| 6 | + |
| 7 | +permissions: |
| 8 | + contents: read # Required to read issue content |
| 9 | + issues: read # Required to read issue details |
| 10 | + |
| 11 | +jobs: |
| 12 | + trigger-devin-chain-validation: |
| 13 | + # This job runs only if the issue was labeled with 'type: new chain request' |
| 14 | + if: | |
| 15 | + github.event.label.name == 'type: new chain request' |
| 16 | + runs-on: ubuntu-latest |
| 17 | + steps: |
| 18 | + - name: Send Slack Notification for Chain Request Validation |
| 19 | + env: |
| 20 | + DEVIN_SLACK_WEBHOOK_URL: ${{ secrets.DEVIN_SLACK_WEBHOOK_URL }} |
| 21 | + DEVIN_SLACK_USER_ID: U08M9DKD4MC |
| 22 | + PROMPT_TEXT: | |
| 23 | + ## Context |
| 24 | +
|
| 25 | + A new issue (#${{ github.event.issue.number }}) has been labeled with "type: new chain request" in the ${{ github.repository }} repository. Your task is to validate this chain request for completeness and take appropriate action. |
| 26 | +
|
| 27 | + **Issue Details:** |
| 28 | + - **Title**: ${{ github.event.issue.title }} |
| 29 | + - **URL**: ${{ github.event.issue.html_url }} |
| 30 | + - **Author**: ${{ github.event.issue.user.login }} |
| 31 | +
|
| 32 | + **Issue Body:** |
| 33 | + ${{ github.event.issue.body }} |
| 34 | +
|
| 35 | + ## Validation Requirements |
| 36 | +
|
| 37 | + Please validate the chain request against the following complete example format: |
| 38 | +
|
| 39 | + **Required Elements:** |
| 40 | + 1. **JSON-RPC spec for Wallets** - Only required if one doesn't already exist (link to existing spec or new spec) |
| 41 | + 2. **CASA namespace spec** - GitHub link to ChainAgnostic/namespaces specification |
| 42 | + 3. **namespaces** - The namespace identifier (e.g., "fil", "eip155") |
| 43 | + 4. **chains** - List of chains with their CAIP-2 identifiers (e.g. "Filecoin [mainnet] fil:f") |
| 44 | + 5. **RPC endpoints** - Working RPC endpoints for each chain |
| 45 | + 6. **SLIP-0044 coin type** - The registered coin type number |
| 46 | + 7. **References section** with: |
| 47 | + - Source of RPC endpoints (with working link) |
| 48 | + - Source of namespace chain information (with working link) |
| 49 | + 8. **Confirmation checkbox** - "I have read and understood the above clarification" must be checked |
| 50 | +
|
| 51 | + ## Your Actions |
| 52 | +
|
| 53 | + **If the request is INCOMPLETE or INVALID:** |
| 54 | + - Comment on the issue with a detailed summary of what is missing or incorrect |
| 55 | + - Be specific about which required elements are missing |
| 56 | + - Provide guidance on how to fix the issues |
| 57 | + - Use a helpful and constructive tone |
| 58 | +
|
| 59 | + **If the request is COMPLETE and VALID:** |
| 60 | + - Create a pull request in the https://github.com/reown-com/web-monorepo/ repository |
| 61 | + - Use the title: "chore: add new chains" |
| 62 | + - Use this PR as a reference for structure and format: https://github.com/reown-com/web-monorepo/pull/1923 |
| 63 | + - Include all the chain information from the validated issue |
| 64 | + - Reference the original issue in the PR description |
| 65 | +
|
| 66 | + ## Repositories Access Required |
| 67 | + * ${{ github.repository }} (for commenting on the issue if needed) |
| 68 | + * reown-com/web-monorepo (for creating the PR if request is valid) |
| 69 | +
|
| 70 | + Please proceed with validating issue #${{ github.event.issue.number }} and take the appropriate action based on your assessment. |
| 71 | + run: | |
| 72 | + # Exit on error |
| 73 | + set -e |
| 74 | +
|
| 75 | + # Check if the Slack webhook URL is provided and not empty |
| 76 | + if [ -z "${DEVIN_SLACK_WEBHOOK_URL}" ]; then |
| 77 | + echo "Error: DEVIN_SLACK_WEBHOOK_URL is not set or is empty." |
| 78 | + echo "Please ensure this secret is configured in the repository settings (Secrets and variables > Actions)." |
| 79 | + exit 1 |
| 80 | + fi |
| 81 | +
|
| 82 | + # PROMPT_TEXT is set in the 'env' block and should be fully expanded by GitHub Actions. |
| 83 | + # Construct the final message text for Slack. |
| 84 | + MESSAGE_TEXT="<@${DEVIN_SLACK_USER_ID}> ${PROMPT_TEXT}" |
| 85 | +
|
| 86 | + # Create the JSON payload for Slack. |
| 87 | + # The --arg option in jq handles escaping special characters in MESSAGE_TEXT for valid JSON. |
| 88 | + echo "Attempting to create JSON payload..." |
| 89 | + JSON_PAYLOAD=$(jq -n --arg text "$MESSAGE_TEXT" '{text: $text}') |
| 90 | + JQ_EXIT_CODE=$? |
| 91 | +
|
| 92 | + if [ $JQ_EXIT_CODE -ne 0 ]; then |
| 93 | + echo "Error: jq command failed to create JSON payload (Exit Code: $JQ_EXIT_CODE)." |
| 94 | + # Log a snippet of the message text to aid debugging, avoiding overly long logs. |
| 95 | + echo "Original Message Text (first 200 characters):" |
| 96 | + echo "${MESSAGE_TEXT:0:200}..." |
| 97 | + exit 1 |
| 98 | + fi |
| 99 | +
|
| 100 | + echo "Sending Slack notification for Chain Request Validation." |
| 101 | + # Echo context information using direct GitHub context expressions for clarity and consistency. |
| 102 | + echo "Repository: ${{ github.repository }}" |
| 103 | + echo "Issue Number: #${{ github.event.issue.number }}" |
| 104 | + echo "Issue Title: ${{ github.event.issue.title }}" |
| 105 | + echo "Issue URL: ${{ github.event.issue.html_url }}" |
| 106 | + echo "Label Added: ${{ github.event.label.name }}" |
| 107 | +
|
| 108 | + # Send the notification to Slack using curl. |
| 109 | + # -s: silent mode (no progress meter). |
| 110 | + # -X POST: specifies the HTTP POST method. |
| 111 | + # -H "Content-Type: application/json": sets the content type header. |
| 112 | + # -d "$JSON_PAYLOAD": provides the JSON data for the request body. |
| 113 | + RESPONSE=$(curl -s -X POST \ |
| 114 | + -H "Content-Type: application/json" \ |
| 115 | + -d "$JSON_PAYLOAD" \ |
| 116 | + "${DEVIN_SLACK_WEBHOOK_URL}") |
| 117 | + CURL_EXIT_CODE=$? |
| 118 | +
|
| 119 | + if [ $CURL_EXIT_CODE -ne 0 ]; then |
| 120 | + echo "Error: curl command failed to send Slack notification (Exit Code: $CURL_EXIT_CODE)." |
| 121 | + # RESPONSE might be empty or contain an error message from curl itself (e.g., if URL is malformed or network issue). |
| 122 | + echo "Curl response (if any): $RESPONSE" |
| 123 | + exit 1 |
| 124 | + fi |
| 125 | +
|
| 126 | + # Check the content of the response from the Slack API. |
| 127 | + # A successful Slack webhook POST request typically returns the string "ok". |
| 128 | + if [ "$RESPONSE" = "ok" ]; then |
| 129 | + echo "Slack notification sent successfully." |
| 130 | + else |
| 131 | + echo "Error sending Slack notification: Slack API did not return 'ok'." |
| 132 | + echo "Response from Slack: $RESPONSE" |
| 133 | + exit 1 |
| 134 | + fi |
0 commit comments