Skip to content

Update deploy.yml #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 55 additions & 40 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
# Sample workflow for building and deploying a VitePress site to GitHub Pages
#
name: Deploy VitePress site to Pages
name: Deploy & Announce Release

on:
# Runs on pushes targeting the `main` branch. Change this to `master` if you're
# using the `master` branch as the default branch.
# Runs on pushes to the `main` branch
push:
branches: [main]

# Allows you to run this workflow manually from the Actions tab
# Allow manual triggering from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
# Permissions needed for GitHub Pages deployment
permissions:
contents: read
pages: write
id-token: write

# Prevent overlapping deploys
concurrency:
group: pages
cancel-in-progress: false
Expand All @@ -25,80 +23,98 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- name: "☁️ checkout repository"
- name: ☁️ Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

fetch-depth: 0 # Needed for full commit history (e.g. for changelogs)


- name: "🔧 setup pnpm"
- name: 🔧 Setup pnpm
uses: pnpm/action-setup@v3
with:
version: 9

- name: "🔧 setup node"
- name: 🔧 Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: "pnpm"
cache: pnpm

- name: "🔧 setup pages"
- name: 🔧 Setup GitHub Pages
uses: actions/configure-pages@v4

- name: "📦 install dependencies"
- name: 📦 Install dependencies
run: pnpm install

# Set up GitHub Actions caching for Wireit.
- name: "🔌 setup wireit cache"
- name: 🔌 Setup Wireit cache
uses: google/wireit@setup-github-actions-caching/v2

- name: "🧱 build docs"
- name: 🧱 Build docs
run: pnpm docs:build

- name: "🗄️ upload pages artifact"
- 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 }}
needs: build
runs-on: ubuntu-latest
name: Deploy
steps:
- name: "🚀 deploy to github pages"
- name: 🔄 Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4


telegram-announcement:
name: 📣 Announcement on Telegram
telegram:
name: 📣 Announce on Telegram
needs: build
runs-on: ubuntu-latest
steps:
- name: 📦 Extract released packages
- name: 🔍 Fetch latest merged PR via GitHub API
id: fetch_pr
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
run: |
# Fetch latest merged PR to main
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

# Extract relevant fields
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)
sed -n '/"body":/,$p' pr.json | sed '1s/.*"body": "//; s/",$//' > pr_body.md

# Export to env
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 "${{ github.event.pull_request.body }}" > pr_body.md
# Extract all lines starting with '## '

# Extract lines starting with '## ' from PR body (i.e., package names)
grep '^## ' pr_body.md | sed 's/^## //' > packages.txt
# Generate HTML list of links to releases

# Generate Telegram HTML links to each released package
while read -r line; do
ENCODED_TAG=$(echo "$line" | jq -sRr @uri) # encode the tag for URL safety
ENCODED_TAG=$(printf "%s" "$line" | jq -sRr @uri)
echo " • <a href=\"$REPO/releases/tag/$ENCODED_TAG\">$line</a>"
done < packages.txt > release_links.html

# Export formatted list to env
{
echo "RELEASE_LINKS<<EOF"
cat release_links.html
echo "EOF"
} >> "$GITHUB_ENV"


- name: 💬 Send Telegram Message
uses: appleboy/telegram-action@master
Expand All @@ -107,8 +123,7 @@ jobs:
token: ${{ secrets.TELEGRAM_TOKEN }}
format: html
message: |
🚀 <b><a href="https://github.com/${{ github.repository }}">${{ github.repository }}</a></b> was just released!
${{ env.RELEASE_LINKS }}

🔗 PR: <a href="${{ github.event.pull_request.html_url }}"><b>${{ github.event.pull_request.title }}</b>#${{ github.event.pull_request.number }}</a>

🚀 <b><a href="https://github.com/${{ github.repository }}">${{ github.repository }}</a></b> was just released!\n
📦 <b>Released Packages:</b>\n
${{ env.RELEASE_LINKS }}\n
🔗 PR: <a href="${{ env.PR_URL }}"><b>${{ env.PR_TITLE }}</b> #${{ env.PR_NUMBER }}</a>