Update welcome.yml #24
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: ZenYukti Welcome & Success Bot | ||
| on: | ||
| pull_request_target: | ||
| types: [opened, closed] | ||
| issues: | ||
| types: [opened] | ||
| permissions: | ||
| issues: write | ||
| pull-requests: write | ||
| contents: read | ||
| jobs: | ||
| zen_bot: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: ZenYukti Automation | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: | | ||
| USER_LOGIN="${{ github.actor }}" | ||
| REPO="${{ github.repository }}" | ||
| BANNER='<picture><source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/ZenYukti/zenyukti.github.io/main/public/assets/branding/gh-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/ZenYukti/zenyukti.github.io/main/public/assets/branding/gh-bright.png"><img alt="ZenYukti Banner" src="https://raw.githubusercontent.com/ZenYukti/zenyukti.github.io/main/public/assets/branding/gh-bright.png" width="800"></picture>' | ||
| # --- CASE 1: FIRST ISSUE --- | ||
| if [[ "${{ github.event_name }}" == "issues" && "${{ github.event.action }}" == "opened" ]]; then | ||
| COUNT=$(curl -s -H "Authorization: Bearer $GH_TOKEN" "https://api.github.com/search/issues?q=author:$USER_LOGIN+repo:$REPO+type:issue" | jq '.total_count') | ||
| if [ "$COUNT" -le 1 ]; then | ||
| cat <<EOF > body.txt | ||
| ## Welcome to the ZenYukti Community! 🚀 | ||
| Thank you for opening your first issue! We believe every great project starts with a single conversation. Our team will review this shortly. | ||
| **While you wait, feel free to:** | ||
| * Check our **[CONTRIBUTING Guidelines](https://github.com/ZenYukti/.github/blob/main/CONTRIBUTING.md)** | ||
| * Join our [Discord Server](https://go.zenyukti.in/discord) | ||
| * Explore other **Open Issues** | ||
| $BANNER | ||
| EOF | ||
| fi | ||
| # --- CASE 2: FIRST PR OPENED --- | ||
| elif [[ "${{ github.event_name }}" == "pull_request_target" && "${{ github.event.action }}" == "opened" ]]; then | ||
| COUNT=$(curl -s -H "Authorization: Bearer $GH_TOKEN" "https://api.github.com/search/issues?q=author:$USER_LOGIN+repo:$REPO+type:pr" | jq '.total_count') | ||
| if [ "$COUNT" -le 1 ]; then | ||
| cat <<EOF > body.txt | ||
| ## Yay! You're officially a Contributor! 🎉 | ||
| Huge thanks for opening this Pull Request. Being a contributor to **ZenYukti** is a big deal, and we’re excited to have you on board. | ||
| **Next Steps:** | ||
| 1. A maintainer will review your code soon. | ||
| 2. Please ensure you've linked an **assigned issue** in the description. | ||
| 3. Stay tuned for feedback! | ||
| $BANNER | ||
| EOF | ||
| fi | ||
| # --- CASE 3: FIRST PR MERGED --- | ||
| elif [[ "${{ github.event_name }}" == "pull_request_target" && "${{ github.event.pull_request.merged }}" == "true" ]]; then | ||
| COUNT=$(curl -s -H "Authorization: Bearer $GH_TOKEN" "https://api.github.com/search/issues?q=author:$USER_LOGIN+repo:$REPO+type:pr+is:merged" | jq '.total_count') | ||
| if [ "$COUNT" -eq 1 ]; then | ||
| cat <<EOF > body.txt | ||
| ## Mission Accomplished! 🏆 | ||
| Congratulations on merging your first PR into ZenYukti! Your code is now officially part of the project. | ||
| We appreciate your hard work and can't wait to see what you build next. Keep the momentum going! | ||
| $BANNER | ||
| EOF | ||
| fi | ||
| fi | ||
| # --- SEND THE COMMENT --- | ||
| if [ -f body.txt ]; then | ||
| JSON_BODY=$(jq -Rs . < body.txt) | ||
| curl -L -X POST \ | ||
| -H "Accept: application/vnd.github+json" \ | ||
| -H "Authorization: Bearer $GH_TOKEN" \ | ||
| https://api.github.com/repos/$REPO/issues/${{ github.event.issue.number || github.event.pull_request.number }}/comments \ | ||
| -d "{\"body\": $JSON_BODY}" | ||
| fi | ||