Skip to content

Add yt custom user agent change #1190

Add yt custom user agent change

Add yt custom user agent change #1190

name: Publish Test URL
on:
pull_request:
jobs:
publish-config:
runs-on: ubuntu-latest
concurrency:
group: test-url
cancel-in-progress: false
steps:
- name: Checkout the repository
uses: actions/checkout@v5
- name: Use Node.js 20
uses: actions/setup-node@v4
with:
node-version: 20.x
- name: Install dependencies
run: npm ci
- uses: ./
- name: build
run: npm run build
- name: Checkout preview-pages branch
uses: actions/checkout@v5
with:
ref: preview-pages
path: pages-branch
token: ${{ secrets.GITHUB_TOKEN }}
- name: Copy PR content into pages branch
run: |
PR_DIR="pr-${{ github.event.pull_request.number }}"
TARGET_DIR="pages-branch/$PR_DIR"
rm -rf "$TARGET_DIR"
mkdir -p "$TARGET_DIR"
cp -r generated/* "$TARGET_DIR"
cd pages-branch
git config user.name "github-actions"
git config user.email "actions@github.com"
git add .
git commit -m "Publish config for PR #${{ github.event.pull_request.number }}" || echo "No changes to commit"
git push origin preview-pages
- name: Generate preview links
id: generate_preview_links
run: |
PR_NUMBER=${{ github.event.pull_request.number || 'unknown' }}
PREVIEW_LINKS=$(find generated/v4 -type f | while read -r file; do
RELATIVE_PATH=${file#generated/v4/}
echo "- [${RELATIVE_PATH}](https://${{ github.repository_owner }}.github.io/$(basename "${{ github.repository }}")/pr-${PR_NUMBER}/v4/${RELATIVE_PATH})"
done)
LAST_UPDATED=$(date -u +"%Y-%m-%d %H:%M:%S UTC")
echo "preview_links<<EOF" >> $GITHUB_OUTPUT
echo "$PREVIEW_LINKS" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
echo "last_updated=$LAST_UPDATED" >> $GITHUB_OUTPUT
- name: Comment preview link on PR
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: peter-evans/create-or-update-comment@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.repository }}
issue-number: ${{ github.event.pull_request.number }}
edit-mode: replace
body: |
🔗 **Preview Config for PR #${{ github.event.pull_request.number }}**
${{ steps.generate_preview_links.outputs.preview_links }}
_Last updated: ${{ steps.generate_preview_links.outputs.last_updated }}_