-
Notifications
You must be signed in to change notification settings - Fork 22
79 lines (69 loc) · 2.34 KB
/
build_and_publish.yml
File metadata and controls
79 lines (69 loc) · 2.34 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
name: build_and_publish
on:
push:
branches:
- trunk
tags:
- v*
pull_request:
workflow_dispatch:
permissions:
contents: write
deployments: write
pull-requests: write
jobs:
deploy:
runs-on: ubuntu-latest
name: Deploy
permissions:
contents: write
deployments: write
pull-requests: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 18
- name: Install dependencies
working-directory: website
run: npm install
- name: Build website
working-directory: website
run: npm run build
- name: Can Deploy?
id: can_deploy
run: |
if [[ "${{ secrets.CLOUDFLARE_API_TOKEN }}" == "" || "${{ secrets.CLOUDFLARE_ACCOUNT_ID }}" == "" ]]; then
echo "CLOUDFLARE_API_TOKEN or CLOUDFLARE_ACCOUNT_ID is not set. Skipping deployment."
echo "can_deploy=false" >> $GITHUB_OUTPUT
else
echo "can_deploy=true" >> $GITHUB_OUTPUT
fi
- name: Deploy
id: deploy
if: ${{ steps.can_deploy.outputs.can_deploy == 'true' }}
uses: cloudflare/wrangler-action@v3
with:
workingDirectory: website
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: pages deploy build --project-name=spiceai-org-website --branch ${{ github.ref_name }}
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
- name: Add deploy comment to PR
if: ${{ github.event_name == 'pull_request' && steps.can_deploy.outputs.can_deploy == 'true' }}
uses: actions/github-script@v7
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '🚀 deployed to <${{ steps.deploy.outputs.deployment-url }}>'
})
- name: Trigger search reindex after deployment
if: ${{ github.ref == 'refs/heads/trunk' }}
run: |
curl -X POST "https://crawler.algolia.com/api/1/crawlers/${{ secrets.ALGOLIA_CRAWLER_ID }}/reindex" \
--user "${{ secrets.ALGOLIA_USER_ID }}":"${{ secrets.ALGOLIA_TOKEN }}"