-
Notifications
You must be signed in to change notification settings - Fork 278
119 lines (106 loc) · 3.89 KB
/
deploy-preview.yaml
File metadata and controls
119 lines (106 loc) · 3.89 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
117
118
119
name: Deploy Preview
on:
pull_request:
types: [opened, synchronize, reopened]
branches:
- main
paths:
- 'packages/website/**'
- 'docs/**'
- '*.md'
- 'README.md'
- 'packages/base/src/**/*.css'
- 'packages/base/src/**/*.ts'
- 'packages/ai/src/**/*.css'
- 'packages/ai/src/**/*.ts'
- 'packages/compat/src/**/*.css'
- 'packages/compat/src/**/*.ts'
- 'packages/fiori/src/**/*.css'
- 'packages/fiori/src/**/*.ts'
- 'packages/main/src/**/*.css'
- 'packages/main/src/**/*.ts'
- '!**/*.spec.ts'
- '!**/*.test.ts'
- '!**/test/**'
jobs:
deploy-preview:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Setup Node.js
uses: actions/setup-node@v4.1.0
with:
node-version: 22
cache: 'yarn'
- name: Install
run: |
export NODE_OPTIONS="--max_old_space_size=4096"
yarn install
- name: Update version.md for PR
run: |
mkdir -p packages/website/static
touch packages/website/static/version.md
echo "PR #${{ github.event.number }} - $(git log -1 --format='%h %s')" > packages/website/static/version.md
echo "Branch: ${{ github.head_ref }}" >> packages/website/static/version.md
echo "Commit: $(git rev-parse HEAD)" >> packages/website/static/version.md
- name: Build
env:
DEPLOYMENT_TYPE: "netlify_preview"
DEPLOYMENT_NETLIFY_PREVIEW_BASE_URL: "https://pr-${{ github.event.number }}--ui5-webcomponents-preview.netlify.app"
PR_NUMBER: "${{ github.event.number }}"
run: |
yarn ci:deploy:preview
- name: Check PR status
id: final-pr-check
if: always()
uses: actions/github-script@v7
with:
github-token: ${{ secrets.UI5_WEBCOMP_BOT_GH_TOKEN }}
script: |
const { data: pr } = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number
});
if (pr.state !== 'open') {
console.log(`PR #${pr.number} was closed during build, skipping deployment`);
core.setOutput('should_deploy', 'false');
return;
}
console.log(`PR #${pr.number} is still open, proceeding with deployment`);
core.setOutput('should_deploy', 'true');
- name: Config Netlify CORS
if: steps.final-pr-check.outputs.should_deploy == 'true'
run: |
cat > packages/website/build/netlify.toml << 'EOF'
[build]
publish = "."
# CORS headers for local-cdn resources
[[headers]]
for = "/local-cdn/*"
[headers.values]
Access-Control-Allow-Origin = "*"
Access-Control-Allow-Methods = "GET, HEAD, OPTIONS"
Access-Control-Allow-Headers = "Content-Type, Accept"
Access-Control-Max-Age = "86400"
Cache-Control = "public, max-age=31536000, immutable"
EOF
- name: Deploy
if: steps.final-pr-check.outputs.should_deploy == 'true'
uses: nwtgck/actions-netlify@v3.0
with:
publish-dir: './packages/website/build'
production-deploy: false
github-token: ${{ secrets.UI5_WEBCOMP_BOT_GH_TOKEN }}
deploy-message: "Deploy preview for PR #${{ github.event.number }}"
alias: pr-${{ github.event.number }}
enable-pull-request-comment: true
enable-commit-comment: false
overwrites-pull-request-comment: true
github-deployment-environment: preview
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}