Merge pull request #3 from Transia-RnD/main #10
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: Dispatch Create UNL | |
| on: | |
| push: | |
| branches: [main] | |
| paths: ["data/unl-raw.yaml"] | |
| workflow_dispatch: | |
| inputs: | |
| dry_run: | |
| description: "Run without uploading to GCP" | |
| required: false | |
| default: "false" | |
| jobs: | |
| dispatch: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| actions: read | |
| steps: | |
| - name: Write private key to file | |
| run: echo "${{ secrets.AUTOMATOR_PRIVATE_KEY }}" | base64 -d > app-private-key.pem | |
| - name: Generate GitHub App token | |
| id: generate_token | |
| run: | | |
| AUTOMATOR_APP_ID="${{ secrets.AUTOMATOR_APP_ID }}" | |
| AUTOMATOR_INSTALL_ID="${{ secrets.AUTOMATOR_INSTALL_ID }}" | |
| NOW=$(date +%s) | |
| EXP=$((NOW + 540)) | |
| HEADER=$(echo -n '{"alg":"RS256","typ":"JWT"}' | openssl base64 -A | tr '+/' '-_' | tr -d '=') | |
| PAYLOAD=$(echo -n "{\"iat\":$NOW,\"exp\":$EXP,\"iss\":\"$AUTOMATOR_APP_ID\"}" | openssl base64 -A | tr '+/' '-_' | tr -d '=') | |
| SIGNATURE=$(printf "%s.%s" "$HEADER" "$PAYLOAD" | openssl dgst -sha256 -sign app-private-key.pem | openssl base64 -A | tr '+/' '-_' | tr -d '=') | |
| JWT="$HEADER.$PAYLOAD.$SIGNATURE" | |
| echo "::add-mask::$JWT" | |
| ACCESS_TOKEN=$(curl -s -X POST \ | |
| -H "Authorization: Bearer $JWT" \ | |
| -H "Accept: application/vnd.github+json" \ | |
| https://api.github.com/app/installations/$AUTOMATOR_INSTALL_ID/access_tokens | jq -r '.token') | |
| echo "::add-mask::$ACCESS_TOKEN" | |
| echo "token=$ACCESS_TOKEN" >> $GITHUB_OUTPUT | |
| - name: Trigger automation workflow | |
| run: | | |
| curl --fail-with-body --silent --show-error \ | |
| -X POST https://api.github.com/repos/XRPLF/unl-automation/dispatches \ | |
| -H "Authorization: Bearer ${{ steps.generate_token.outputs.token }}" \ | |
| -H "Accept: application/vnd.github+json" \ | |
| -d '{ | |
| "event_type": "run-unl-job", | |
| "client_payload": { | |
| "dry_run": "${{ github.event.inputs.dry_run || 'false' }}" | |
| } | |
| }' |