Release v2.1.0 - bridge-hub #536
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Test Trigger On Comment | |
| on: | |
| issue_comment: | |
| types: [created] | |
| jobs: | |
| trigger-remote-test: | |
| if: github.event.issue.pull_request | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check team membership | |
| id: check-team | |
| env: | |
| GH_TOKEN: ${{ secrets.PASEO_CI_PAT }} | |
| run: | | |
| response=$(curl -s \ | |
| -H "Accept: application/vnd.github+json" \ | |
| -H "Authorization: Bearer $GH_TOKEN" \ | |
| -H "X-GitHub-Api-Version: 2022-11-28" \ | |
| "https://api.github.com/orgs/paseo-network/teams/paseo-core/memberships/${{ github.event.comment.user.login }}") | |
| if [ "$(echo "$response" | jq -r '.state // empty')" == "active" ]; then | |
| echo "is_allowed=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "is_allowed=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Check comment content | |
| if: steps.check-team.outputs.is_allowed == 'true' | |
| id: check-comment | |
| run: | | |
| comment="${{ github.event.comment.body }}" | |
| if [[ "$comment" =~ ^/bot.* ]]; then | |
| echo "is_bot_command=true" >> $GITHUB_OUTPUT | |
| echo "command=$comment" >> $GITHUB_OUTPUT | |
| echo $command | |
| else | |
| echo "is_bot_command=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Get PR Details | |
| if: steps.check-comment.outputs.is_bot_command == 'true' && steps.check-team.outputs.is_allowed == 'true' | |
| id: pr-details | |
| env: | |
| GH_TOKEN: ${{ secrets.PASEO_CI_PAT }} | |
| run: | | |
| pr_data=$(curl -L \ | |
| -H "Accept: application/vnd.github+json" \ | |
| -H "Authorization: Bearer $GH_TOKEN" \ | |
| -H "X-GitHub-Api-Version: 2022-11-28" \ | |
| "https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.issue.number }}") | |
| pr_branch=$(echo "$pr_data" | jq -r .head.ref) | |
| echo "branch=$pr_branch" >> $GITHUB_OUTPUT | |
| - name: Trigger Remote Test Workflow | |
| if: steps.check-comment.outputs.is_bot_command == 'true' && steps.check-team.outputs.is_allowed == 'true' | |
| env: | |
| GH_TOKEN: ${{ secrets.ZONDAX_CI_PAT }} | |
| run: | | |
| response=$(curl -L \ | |
| -X POST \ | |
| -H "Accept: application/vnd.github+json" \ | |
| -H "Authorization: Bearer $GH_TOKEN" \ | |
| -H "X-GitHub-Api-Version: 2022-11-28" \ | |
| https://api.github.com/repos/Zondax/paseo-runtime-test/actions/workflows/bot-trigger.yml/dispatches \ | |
| -d '{ | |
| "ref": "main", | |
| "inputs": { | |
| "target_repo": "https://github.com/${{ github.repository }}", | |
| "target_branch": "${{ steps.pr-details.outputs.branch }}", | |
| "pr_number": "${{ github.event.issue.number }}", | |
| "command": "${{ steps.check-comment.outputs.command }}" | |
| }' -w "%{http_code}" -o /dev/null) | |
| if [ "$response" != "204" ]; then | |
| echo "Failed to trigger remote test. HTTP status code: $response" | |
| exit 1 | |
| fi |