-
Notifications
You must be signed in to change notification settings - Fork 1.7k
151 lines (141 loc) · 5.94 KB
/
build-docs.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
name: Deploy Docs
on:
push:
branches:
- master
- 'release-*'
paths:
- docs/**
- examples/docs_snippets/**
- examples/docs_projects/**
- examples/getting_started_etl_tutorial/**
- examples/airlift-migration-tutorial/**
- .github/workflows/build-docs.yml
- '!docs/README.md'
- '!docs/CONTRIBUTING.md'
- '!docs/content-templates/**'
# Required for `yarn rebuild-kinds-tags`
- js_modules/dagster-ui/packages/ui-core/src/graph/OpTags.tsx
pull_request:
paths:
- docs/**
- examples/docs_snippets/**
- examples/docs_projects/**
- examples/getting_started_etl_tutorial/**
- examples/airlift-migration-tutorial/**
- .github/workflows/build-docs.yml
- '!docs/README.md'
- '!docs/CONTRIBUTING.md'
- '!docs/content-templates/**'
# Required for `yarn rebuild-kinds-tags`
- js_modules/dagster-ui/packages/ui-core/src/graph/OpTags.tsx
types:
- opened
- reopened
- synchronize
- ready_for_review
concurrency:
group: ${{ github.workflow}}-${{github.ref}}
cancel-in-progress: true
jobs:
deploy:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
# Deploy to Vercel Previews on pull request, push to master branch
steps:
- name: Get branch preview subdomain
env:
HEAD_REF: ${{ github.head_ref }}
REF_NAME: ${{ github.ref_name }}
if: |
github.event_name == 'pull_request' || (
github.event_name == 'push' && (
github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release-')
)
)
run: |
BRANCH_PREVIEW_SUBDOMAIN=$(echo "${HEAD_REF:-$REF_NAME}" | sed -e 's/[^a-zA-Z0-9-]/-/g; s/^-*//; s/-*$//' | cut -c1-63)
BRANCH_PREVIEW_SUBDOMAIN=$(echo $BRANCH_PREVIEW_SUBDOMAIN | sed 's/--/-/g; s/-$//')
echo "$BRANCH_PREVIEW_SUBDOMAIN"
echo "BRANCH_PREVIEW_SUBDOMAIN=$BRANCH_PREVIEW_SUBDOMAIN" >> "${GITHUB_ENV}"
- name: Get fetch depth
run: |
if [[ ${{ github.event_name }} == 'pull_request' ]]; then
echo "FETCH_DEPTH=$(( ${{ github.event.pull_request.commits }} + 1 ))" >> $GITHUB_ENV
else
echo "FETCH_DEPTH=1" >> $GITHUB_ENV
fi
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: ${{ env.FETCH_DEPTH }}
- name: Install node
uses: actions/setup-node@v4
with:
node-version: 18
- name: Lint Docs
run: |
cd docs
yarn install
yarn run lint
- name: Get changed docs files for PR comment
if: ${{ github.event.pull_request }}
run: |
cd docs/docs
echo "Head ref is $GITHUB_HEAD_SHA"
git fetch origin $GITHUB_HEAD_SHA
# Compare the commit the branch is based on to its head to list changed files
CHANGED_MD_FILES=$(git diff --name-only HEAD~${{ github.event.pull_request.commits }} "$GITHUB_HEAD_SHA" -- '*.md' '*.mdx')
CHANGES_ENTRY=$(echo "$CHANGED_MD_FILES" | sed 's/\(index\)*\.mdx*$//' | sed 's/^docs\/docs/- {{deploymentUrl}}/')
CHANGES_ENTRY=$(echo -e "Preview available at {{deploymentUrl}}\n\nDirect link to changed pages:\n$CHANGES_ENTRY")
echo "$CHANGES_ENTRY"
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "CHANGES_ENTRY<<$EOF" >> $GITHUB_ENV
echo "$CHANGES_ENTRY" >> $GITHUB_ENV
echo "$EOF" >> $GITHUB_ENV
env:
GITHUB_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
# Commits to pull requests result in preview deployments
- name: Publish Preview to Vercel
uses: amondnet/vercel-action@v25
if: |
github.event_name == 'pull_request'
with:
github-comment: ${{ github.event.pull_request && env.CHANGES_ENTRY || true }}
vercel-token: ${{ secrets.VERCEL_TOKEN }}
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }}
vercel-project-id: ${{ secrets.VERCEL_DOCS_NEXT_PROJECT_ID }}
github-token: ${{ secrets.GITHUB_TOKEN }}
scope: ${{ secrets.VERCEL_ORG_ID }}
alias-domains: ${{ env.BRANCH_PREVIEW_SUBDOMAIN }}.archive.dagster-docs.io
# Pushes to `master` result in a preview deployment with the `main.` domain alias
#
# NOTE: alias must match preview version defined in `docs/dagsterVersions.json`
#
# TODO(colton) - add alias on the `dagster.io` domain
# TODO(colton) - use `-e ENVIRONMENT=...` flag for preview-specific site configuration
- name: Publish Main Preview to Vercel
uses: amondnet/vercel-action@v25
if: |
github.event_name == 'push' && github.ref == 'refs/heads/master'
with:
github-comment: ${{ github.event.pull_request && env.CHANGES_ENTRY || true }}
vercel-token: ${{ secrets.VERCEL_TOKEN }}
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }}
vercel-project-id: ${{ secrets.VERCEL_DOCS_NEXT_PROJECT_ID }}
github-token: ${{ secrets.GITHUB_TOKEN }}
scope: ${{ secrets.VERCEL_ORG_ID }}
alias-domains: main.archive.dagster-docs.io
# Pushes to `release-` prefixed branches result in production deployments on the `docs.dagster.io` domain
- name: Publish to Vercel Production
uses: amondnet/vercel-action@v25
if: |
github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release-')
with:
vercel-token: ${{ secrets.VERCEL_TOKEN }}
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }}
vercel-project-id: ${{ secrets.VERCEL_DOCS_NEXT_PROJECT_ID }}
vercel-args: "--prod"
github-token: ${{ secrets.GITHUB_TOKEN }}
scope: ${{ secrets.VERCEL_ORG_ID }}