Create XXtuFVgEUz13SFPVY6s2cZrnLDEkxQXc19aXrNARwEBeCXgg #137
Workflow file for this run
This file contains 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: PR Validation and Notifications | |
on: | |
pull_request: | |
types: [opened, ready_for_review, review_requested, reopened, closed, synchronize] | |
pull_request_review: | |
types: [submitted] | |
jobs: | |
log_info: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Log PR Info | |
run: | | |
if [ "${{ github.event_name }}" == "pull_request_review" ]; then | |
echo "PR Number: ${{ github.event.pull_request.number }}" | |
echo "Action: ${{ github.event.review.state }}" | |
elif [ "${{ github.event_name }}" == "pull_request" ]; then | |
echo "PR Number: ${{ github.event.number }}" | |
echo "Action: ${{ github.event.action }}" | |
else | |
echo "Unhandled event type: ${{ github.event_name }}" | |
fi | |
- name: Debug Information | |
run: | | |
echo "Test var: ${{ secrets.TEST }}" | |
validate_and_notify: | |
runs-on: ubuntu-latest | |
name: Validate JSON and Notify on Telegram | |
steps: | |
- uses: actions/checkout@v4 | |
name: Checkout Code | |
- name: Check Required Files in Subfolders | |
id: check_files | |
run: | | |
missing_files=false | |
error_message="Missing required files: " | |
# Check each subfolder for info.json, logo.png, and metadata.json | |
for dir in tokens/psp22/*; do | |
if [ ! -d "$dir" ]; then continue; fi # Skip if not a directory | |
echo "Checking directory: $dir" | |
if [ ! -f "$dir/info.json" ]; then | |
missing_files=true | |
error_message="${error_message}info.json is missing in $dir " | |
fi | |
if [ ! -f "$dir/logo.png" ]; then | |
missing_files=true | |
error_message="${error_message}logo.png is missing in $dir " | |
fi | |
if [ ! -f "$dir/metadata.json" ]; then | |
missing_files=true | |
error_message="${error_message}metadata.json is missing in $dir " | |
fi | |
done | |
if [ "$missing_files" = true ]; then | |
echo "$error_message" | |
exit 1 | |
fi | |
- name: JSON/YAML Validation | |
uses: GrantBirki/json-yaml-validate@v2.7.1 | |
with: | |
comment: "true" # This will post a comment if the validation fails | |
- name: Prepare Notification Message | |
if: success() # This will proceed only if the previous validation step was successful | |
run: | | |
message="" | |
pr_link="${{ github.event.pull_request.html_url }}" | |
if [ "${{ github.event_name }}" == "pull_request" ]; then | |
if [ "${{ github.event.action }}" == "opened" ]; then | |
message="π New PR created: #${{ github.event.pull_request.number }} by ${{ github.event.pull_request.user.login }} - $pr_link" | |
elif [ "${{ github.event.action }}" == "ready_for_review" ]; then | |
message="π PR is ready for review: #${{ github.event.pull_request.number }} - $pr_link" | |
elif [ "${{ github.event.action }}" == "reopened" ]; then | |
message="π PR reopened: #${{ github.event.pull_request.number }} - $pr_link" | |
elif [ "${{ github.event.action }}" == "closed" ] && [ "${{ github.event.pull_request.merged }}" == "true" ]; then | |
message="β PR merged: #${{ github.event.pull_request.number }} - $pr_link" | |
elif [ "${{ github.event.action }}" == "closed" ] && [ "${{ github.event.pull_request.merged }}" == "false" ]; then | |
message="β PR closed without merging: #${{ github.event.pull_request.number }} - $pr_link" | |
fi | |
elif [ "${{ github.event_name }}" == "pull_request_review" ] && [ "${{ github.event.review.state }}" == "approved" ]; then | |
message="π PR approved by ${{ github.event.review.user.login }}: #${{ github.event.pull_request.number }} - $pr_link" | |
fi | |
if [ -z "$message" ]; then | |
echo "No relevant action taken, skipping notification." | |
exit 0 | |
fi | |
echo "TG_SENDER_PAYLOAD_MESSAGE=$message" >> $GITHUB_ENV | |
- name: Send Notification to Telegram | |
if: env.TG_SENDER_PAYLOAD_MESSAGE != '' && success() | |
env: | |
TELEGRAM_BOT_TOKEN: ${{ secrets.BOTTOKEN }} | |
TELEGRAM_CHAT_ID: ${{ secrets.CHATID }} | |
run: | | |
curl -X POST \ | |
-H "Content-Type: application/json" \ | |
-d "{\"chat_id\": \"$TELEGRAM_CHAT_ID\", \"text\": \"${{ env.TG_SENDER_PAYLOAD_MESSAGE }}\"}" \ | |
"https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/sendMessage" | |
# if: env.TG_SENDER_PAYLOAD_MESSAGE != '' && success() | |
# run: | | |
# curl -X POST \ | |
# -H "Content-Type: application/json" \ | |
# -d '{"chat_id": "${{ secrets.CHATID }}", "text": "${{ env.TG_SENDER_PAYLOAD_MESSAGE }}"}' \ | |
# "https://api.telegram.org/bot${{ secrets.BotToken }}/sendMessage" |