-
Notifications
You must be signed in to change notification settings - Fork 5
125 lines (117 loc) · 3.95 KB
/
ci-cd-pipeline.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
name: CI/CD
on:
pull_request:
push:
branches:
- main
jobs:
check_broken_links:
name: Check links
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '16.x'
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Build Documentation
run: yarn build
deploy_preview:
needs: check_broken_links
name: Deploy PR Preview
if: ${{ github.event_name == 'pull_request' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: rlespinasse/[email protected]
name: Inject slug/short variables
- uses: bobheadxi/[email protected]
name: Start deployment
id: preview_deployment
with:
step: start
token: ${{ secrets.GITHUB_TOKEN }}
env: ${{ env.GITHUB_HEAD_REF_SLUG_URL }}
ref: ${{ github.head_ref }}
- uses: actions/setup-node@v3
name: Setup Node.js
with:
node-version: lts/*
- uses: amondnet/vercel-action@v20
name: Deploy to Vercel
id: vercel_preview
with:
vercel-token: ${{ secrets.VERCEL_TOKEN }}
github-token: ${{ secrets.GITHUB_TOKEN }}
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }}
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }}
scope: ${{ secrets.VERCEL_SCOPE }}
alias-domains: pr-{{PR_NUMBER}}-superface-docs.${{ secrets.VERCEL_DOMAIN }}
- uses: bobheadxi/[email protected]
name: Finish deployment
if: always()
with:
step: finish
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
deployment_id: ${{ steps.preview_deployment.outputs.deployment_id }}
env_url: ${{ steps.vercel_preview.outputs.preview-url }}
deploy_production:
needs: check_broken_links
name: Deploy to Production
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: bobheadxi/[email protected]
name: Start deployment
id: production_deployment
with:
step: start
token: ${{ secrets.GITHUB_TOKEN }}
auto_inactive: true
env: Production
- uses: actions/setup-node@v3
name: Setup Node.js
with:
node-version: lts/*
- uses: amondnet/vercel-action@v20
name: Deploy to Vercel
id: vercel_production
with:
vercel-token: ${{ secrets.VERCEL_TOKEN }}
github-token: ${{ secrets.GITHUB_TOKEN }}
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }}
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }}
scope: ${{ secrets.VERCEL_SCOPE }}
vercel-args: '--prod'
github-comment: false
- uses: bobheadxi/[email protected]
name: Finish deployment
if: always()
with:
step: finish
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
deployment_id: ${{ steps.production_deployment.outputs.deployment_id }}
env_url: ${{ steps.vercel_production.outputs.preview-url }}
index_production:
needs: deploy_production
name: Index production to Algolia
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: echo ::set-output name=CONFIG::$(cat .github/algolia/config.json | jq -r tostring)
name: Get Scraper config
id: config
- uses: addnab/docker-run-action@v3
name: Scrape and Index docs
with:
image: algolia/docsearch-scraper
options: -e API_KEY -e APPLICATION_ID -e CONFIG
run: pipenv run python -m src.index
env:
API_KEY: ${{ secrets.ALGOLIA_ADMIN_API_KEY }}
APPLICATION_ID: ${{ secrets.ALGOLIA_APPLICATION_ID }}
CONFIG: ${{ steps.config.outputs.CONFIG }}