-
Notifications
You must be signed in to change notification settings - Fork 951
44 lines (36 loc) · 1.51 KB
/
preview-link.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
name: Vercel deployment preview link generator
on:
pull_request:
types: [opened, synchronize]
jobs:
comment-deployment-link:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Wait for Vercel deployment
run: |
echo "Waiting for Vercel deployment to complete..."
sleep 300 # Adjust this based on deployment speed
- name: Get changed files
id: files
run: |
CHANGED_FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep 'website/docs/docs/')
echo "::set-output name=changed_files::${CHANGED_FILES}"
- name: Generate deployment link
id: vercel
run: |
DEPLOYMENT_URL="https://docs-getdbt-${{ github.sha }}-dbt-labs.vercel.app"
CHANGED_FILES=${{ steps.files.outputs.changed_files }}
# Formatting links for each changed file
LINKS=$(echo "$CHANGED_FILES" | awk -v url="$DEPLOYMENT_URL" '{print url "/" $0}')
echo "::set-output name=links::${LINKS}"
- name: Post comment with deployment link
uses: peter-evans/create-or-update-comment@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.pull_request.number }}
body: |
🚀 Deployment available: ${{ steps.vercel.outputs.deployment_url }}
Here are the direct links to the updated files:
${{ steps.vercel.outputs.links }}