-
Notifications
You must be signed in to change notification settings - Fork 3.2k
116 lines (96 loc) · 4.12 KB
/
docs-production.yml
File metadata and controls
116 lines (96 loc) · 4.12 KB
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
name: Docs Production Deployment
env:
GHA_DOCKER_TAG: docker.pkg.github.com/${{ github.repository }}/handsontable-documentation
on:
push:
branches:
- 'prod-docs/**'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
defaults:
run:
working-directory: ./docs/
jobs:
docker:
name: Build and push Docker image
if: ${{ github.ref != 'refs/heads/prod-docs/latest' }} # Exclude the prod-docs-latest branch from triggering the workflow
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # https://github.com/actions/checkout/releases/tag/v6.0.2
- uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # https://github.com/pnpm/action-setup/releases/tag/v4.2.0
name: Install pnpm
- name: Use Node.js
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # https://github.com/actions/setup-node/releases/tag/v6.2.0
with:
node-version-file: '.nvmrc'
cache: 'npm'
cache-dependency-path: docs/package-lock.json
- uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # https://github.com/actions/github-script/releases/tag/v8.0.0
id: get-docs-version
with:
script: return context.ref.match(/^refs\/heads\/prod\-docs\/(\d+\.\d+)$/)[1] ?? '';
result-encoding: string
- name: Validate Docs version
run: if [ -z "${{steps.get-docs-version.outputs.result}}" ]; then echo "Docs version is empty"; exit 1; fi
- name: Docker login into GHCR
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login -u ${GITHUB_ACTOR} --password-stdin https://docker.pkg.github.com
- name: Update module size measurements
working-directory: .
run: |
pnpm install --frozen-lockfile --ignore-scripts
npm run build --prefix handsontable
npm run measure:module-sizes --prefix handsontable
- name: Dependencies
run: |
npm ci
- name: Docker build
run: |
npm run docs:docker:build:production
- name: Test examples
run: |
npm run docs:test:example-checker
- name: Docker tags
run: |
docker tag docs-md:production $GHA_DOCKER_TAG":v${{steps.get-docs-version.outputs.result}}"
docker tag docs-md:production $GHA_DOCKER_TAG":v${{steps.get-docs-version.outputs.result}}-${{ github.sha }}"
- name: Docker push production into GHCR
run: |
docker push $GHA_DOCKER_TAG":v${{steps.get-docs-version.outputs.result}}"
- name: Docker push SHA tagged into GHCR
run: |
docker push $GHA_DOCKER_TAG":v${{steps.get-docs-version.outputs.result}}-${{ github.sha }}"
- name: Build and deploy the production to Netlify (from Docker images)
run: |
cd netlify
mkdir -p docs/docs
./build_current_version.sh
- name: Publish production to Netlify
uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # https://github.com/nick-fields/retry/releases/tag/v3.0.2
with:
timeout_seconds: 1600
max_attempts: 3
retry_on: error
command: |
cd docs
cd netlify
npm install netlify-cli -g
netlify deploy --prod --build --context production
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_PREVIEW_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_PROD_SITE_ID }}
- name: Algolia crawler start
env:
crawler-name: Github Crawler
crawler-id: 8062e3d3-ea11-422a-a31a-3b8003bef6f6
crawler-user-id: 61f462d3-fa0d-465f-8fc1-e39231615539
crawler-api-key: ${{ secrets.CRAWLER_API_KEY }}
site-url: 'https://handsontable.com'
run: |
wget --method POST \
--auth-no-challenge \
--user='${{ env.crawler-user-id }}' \
--password='${{ env.crawler-api-key}}' \
'https://crawler.algolia.com/api/1/crawlers/${{ env.crawler-id }}/reindex'