-
Notifications
You must be signed in to change notification settings - Fork 0
138 lines (117 loc) Β· 4.6 KB
/
build_pr.yaml
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 PR
on:
pull_request:
types: [ opened, synchronize, reopened, ready_for_review ]
jobs:
deploy-pr:
name: 'π§ Build & deploy π'
runs-on: ubuntu-latest
timeout-minutes: 10
# Do not run on WIP or Draft PRs
if: "!github.event.pull_request || github.event.pull_request.draft == false"
steps:
- name: 'Checkout'
uses: actions/checkout@v2
- name: 'Create GitHub deployment'
uses: chrnorm/deployment-action@releases/v1
id: deployment
with:
ref: ${{ github.head_ref }}
token: ${{ secrets.GITHUB_TOKEN }}
target_url: https://elao.github.io/elao-admin/pr/${{ github.event.number }}
environment: staging
# https://github.com/actions/setup-node
- name: 'Setup node'
uses: actions/setup-node@v2
with:
node-version: '16'
- name: 'Setup PHP'
uses: shivammathur/setup-php@v2
with:
coverage: "none"
extensions: "json"
ini-values: "memory_limit=-1"
php-version: "8.2"
- name: 'Determine composer cache directory'
id: composer-cache
run: echo "::set-output name=directory::$(composer config cache-dir)"
working-directory: demo
- name: 'Cache composer dependencies'
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.directory }}
key: composer-${{ hashFiles('demo/composer.lock') }}
- name: 'Cache parent NPM dependencies'
uses: actions/cache@v2
with:
path: ~/.npm
key: node-${{ hashFiles('package-lock.json') }}
- name: 'Cache NPM dependencies'
uses: actions/cache@v2
with:
path: ~/.npm
key: node-${{ hashFiles('demo/package-lock.json') }}
- name: 'Build parent package'
run: |
echo "::group::npm install"
npm install --color=always --no-progress
echo "::endgroup::"
echo "::group::build"
npx webpack --mode=production
echo "::endgroup::"
- name: 'Install dependencies'
working-directory: demo
run: |
echo "::group::composer install"
composer install --no-progress --ansi
echo "::endgroup::"
echo "::group::npm install"
npm install --color=always --no-progress
echo "::endgroup::"
- name: 'Warmup'
working-directory: demo
run: |
echo "::group::warmup production env"
npx encore production --color
bin/console cache:clear --ansi
bin/console cache:warmup --ansi
echo "::endgroup::"
env:
APP_ENV: prod
WEBPACK_PUBLIC_PATH: /elao-admin/pr/${{ github.event.number }}/build
- name: 'Build static site'
working-directory: demo
run: bin/console stenope:build build --no-interaction -vv --ansi --ignore-content-not-found
env:
APP_ENV: prod
ROUTER_DEFAULT_URI: https://elao.github.io/elao-admin/pr/${{ github.event.number }}
# https://github.com/marketplace/actions/deploy-to-github-pages
- name: 'π Deploy'
uses: JamesIves/[email protected]
with:
COMMIT_MESSAGE: |
[AUTO] Deploy PR #${{ github.event.number }}
for commit ${{ github.sha }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: gh-pages # The branch the action should deploy to.
FOLDER: demo/build # The folder the action should deploy.
TARGET_FOLDER: pr/${{ github.event.number }} # The folder where the action should deploy on the deployment branch.
CLEAN: true # Automatically remove deleted files from the deploy branch
- name: 'Update deployment status (success)'
if: success()
uses: chrnorm/deployment-status@releases/v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
description: "Deployed PR #${{ github.event.number }}"
target_url: https://elao.github.io/elao-admin/pr/${{ github.event.number }}/
environment_url: https://elao.github.io/elao-admin/pr/${{ github.event.number }}/
state: "success"
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
- name: 'Update deployment status (failure)'
if: failure()
uses: chrnorm/deployment-status@releases/v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
description: "Failed to deploy PR #${{ github.event.number }}"
state: "failure"
deployment_id: ${{ steps.deployment.outputs.deployment_id }}