Skip to content

Merge pull request #26 from code-with-amirhossein/amir78729-patch-27 #41

Merge pull request #26 from code-with-amirhossein/amir78729-patch-27

Merge pull request #26 from code-with-amirhossein/amir78729-patch-27 #41

Workflow file for this run

name: Deploy & Announce Release
on:
push:
branches: [main]
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: pages
cancel-in-progress: false
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: ☁️ Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: 🔧 Setup pnpm
uses: pnpm/action-setup@v3
with:
version: 9
- name: 🔧 Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
- name: 🔧 Setup GitHub Pages
uses: actions/configure-pages@v4
- name: 📦 Install dependencies
run: pnpm install
- name: 🔌 Setup Wireit cache
uses: google/wireit@setup-github-actions-caching/v2
- name: 🧱 Build docs
run: pnpm docs:build
- name: 🗄️ Upload Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: .vitepress/dist
deploy:
name: 🚀 Deploy to GitHub Pages
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: 🔄 Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
telegram:
name: 📣 Announce on Telegram
needs: build
runs-on: ubuntu-latest
steps:
- name: 🔍 Fetch latest merged PR via GitHub API
id: fetch_pr
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
run: |
curl -s -H "Authorization: token $GH_TOKEN" \
"https://api.github.com/repos/$REPO/pulls?state=closed&base=main&sort=updated&direction=desc&per_page=1" \
-o pr.json
PR_NUMBER=$(grep '"number":' pr.json | head -n 1 | awk '{print $2}' | tr -d ',')
PR_TITLE=$(grep '"title":' pr.json | head -n 1 | cut -d ':' -f2- | sed 's/^ "//;s/",$//')
PR_URL=$(grep '"html_url":' pr.json | head -n 1 | cut -d '"' -f4)
PR_BODY=$(awk -F'"body": "' '{print $2}' pr.json | sed 's/",$//')
echo "$PR_BODY" > pr_body.md
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
echo "PR_TITLE=$PR_TITLE" >> $GITHUB_ENV
echo "PR_URL=$PR_URL" >> $GITHUB_ENV
- name: 📦 Extract released packages from PR body
id: extract
run: |
REPO="https://github.com/${{ github.repository }}"
echo "🔍 PR body content:" && cat pr_body.md
# Use grep with flexible spacing
grep -E '^\s*##\s+@' pr_body.md | sed -E 's/^\s*##\s+//' > packages.txt
echo "🔍 Extracted packages:"
cat packages.txt
if [ -s packages.txt ]; then
while read -r line; do
ENCODED_TAG=$(printf "%s" "$line" | jq -sRr @uri)
echo " • <a href=\"$REPO/releases/tag/$ENCODED_TAG\">$line</a>"
done < packages.txt > release_links.html
else
echo " • No packages found." > release_links.html
fi
{
echo "RELEASE_LINKS<<EOF"
cat release_links.html
echo "EOF"
} >> "$GITHUB_ENV"
- name: 💬 Send Telegram Message
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
format: html
message: |
🚀 <b><a href="https://github.com/${{ github.repository }}">${{ github.repository }}</a></b> was just released!
<b>Released Packages:</b>
${{ env.RELEASE_LINKS }}
🔗 <a href="${{ env.PR_URL }}"><b>${{ env.PR_TITLE }}</b> #${{ env.PR_NUMBER }}</a>