-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
138 lines (135 loc) · 5.26 KB
/
example-previews.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
name: Deploy Example Previews
on:
issue_comment:
types: [created]
pull_request:
types:
- opened
- synchronize
- reopened
- labeled
push:
branches:
- master
workflow_dispatch:
inputs:
example_name:
description: "Example name to deploy preview"
type: choice
required: true
options:
- finefoods-antd
- finefoods-client
- finefoods-material-ui
- app-crm
- pixels
- invoicer
jobs:
changes:
runs-on: ubuntu-latest
# Required permissions
permissions:
pull-requests: read
# Set job outputs to values from filter step
outputs:
examples: ${{ steps.filter.outputs.changes }}
all_examples: ${{ steps.deploy-previews-label.outputs.all_examples || '[]' }}
dispatch_example: ${{ join(inputs.example_name) || '[]' }}
steps:
- name: Get PR labels
id: pr-labels
uses: joerick/[email protected]
# For pull requests it's not necessary to checkout the code
- name: 'Check deploy previews label'
id: deploy-previews-label
run: echo 'all_examples=["finefoods-antd", "finefoods-client", "finefoods-material-ui", "app-crm", "pixels", "invoicer"]' >> $GITHUB_OUTPUT
if: ${{ contains(steps.pr-labels.outputs.labels, ' deploy-previews ') }}
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
'finefoods-antd': 'examples/finefoods-antd/**'
'finefoods-client': 'examples/finefoods-client/**'
'finefoods-material-ui': 'examples/finefoods-material-ui/**'
'app-crm': 'examples/app-crm/**'
'pixels': 'examples/pixels/**'
'invoicer': 'examples/invoicer/**'
deploy_example_preview:
permissions:
pull-requests: read
issues: read
outputs:
example_name: ${{ steps.set-example-name.outputs.example_name }}
runs-on: ubuntu-latest
if: ${{ contains(github.event.comment.body, '/deploy') }}
steps:
- name: Set Example Name
id: set-example-name
run: echo "EXAMPLE_NAME=$(echo ${{ github.event.comment.body }} | cut -f 2 -d ' ')" >> $GITHUB_ENV
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
with:
version: 9
- uses: actions/setup-node@v4
with:
node-version: 18
cache: "pnpm"
- name: Install Dependencies
run: pnpm install --ignore-scripts
- name: Build example
run: pnpm build --scope ${{ env.EXAMPLE_NAME }}
- name: test path
run: ls -l ${{ format('./examples/{0}/{1}', env.EXAMPLE_NAME, contains(fromJson('["finefoods-client"]'), env.EXAMPLE_NAME) && '.next' || 'dist') }}
- name: Deploy to Netlify
uses: nwtgck/[email protected]
with:
publish-dir: ${{ format('./examples/{0}/{1}', env.EXAMPLE_NAME, contains(fromJson('["finefoods-client"]'), env.EXAMPLE_NAME) && '.next' || 'dist') }}
github-token: ${{ secrets.PANKOD_BOT_TOKEN }}
deploy-message: "Deploy from GitHub Actions"
alias: deploy-preview-${{ env.EXAMPLE_NAME }}-${{ github.event.comment.node_id }}
enable-pull-request-comment: false
overwrites-pull-request-comment: false
github-deployment-environment: "deploy-preview-${{ env.EXAMPLE_NAME }}-${{ github.event.comment.node_id }}"
netlify-config-path: ./examples/${{ env.EXAMPLE_NAME }}/netlify.toml
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
timeout-minutes: 10
preview:
runs-on: ubuntu-latest
needs: changes
strategy:
fail-fast: false
max-parallel: 6
matrix:
example: ${{ fromJSON(needs.changes.outputs.all_examples) || fromJSON(needs.changes.outputs.examples) || fromJSON(needs.changes.outputs.dispatch_example) || '[]' }}
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
with:
version: 9
- uses: actions/setup-node@v4
with:
node-version: 18
cache: "pnpm"
- name: Install Dependencies
run: pnpm install --ignore-scripts
- name: Build example
run: pnpm build --scope ${{ matrix.example }}
- name: test path
run: ls -l ${{ format('./examples/{0}/{1}', matrix.example, contains(fromJson('["finefoods-client"]'), matrix.example) && '.next' || 'dist') }}
- name: Deploy to Netlify
uses: nwtgck/[email protected]
with:
publish-dir: ${{ format('./examples/{0}/{1}', matrix.example, contains(fromJson('["finefoods-client"]'), matrix.example) && '.next' || 'dist') }}
github-token: ${{ secrets.PANKOD_BOT_TOKEN }}
deploy-message: "Deploy from GitHub Actions"
alias: deploy-preview-${{ matrix.example }}-${{ github.event.number }}
enable-pull-request-comment: false
overwrites-pull-request-comment: false
github-deployment-environment: "deploy-preview-${{ matrix.example }}-${{ github.event.number }}"
netlify-config-path: ./examples/${{ matrix.example }}/netlify.toml
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
timeout-minutes: 10