-
Notifications
You must be signed in to change notification settings - Fork 0
85 lines (82 loc) · 3.08 KB
/
delivery.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
name: Delivery
on:
pull_request:
types: closed
branches: develop
env:
NODE_VERSION: 16.x
LAUNCH_BUILD: off # Launch Build. [ on, off ]
LAUNCH_DEPLOY: off # Launch Deployment. [ on, off ]
DEPLOY_TYPE: github-pages # Deploy Type. [ github-pages, netlify, ftp ]
ENDPOINT_GITHUB_PAGES: # When Using GitHub Pages, Add Endpoint.
ENDPOINT_NETLIFY: # When Using Netlify, Add Endpoint.
ENDPOINT_FTP: # When Using FTP, Add Endpoint.
ENDPOINT_REDIRECT: # When Create SPA & Deploy on GitHub Pages, Add GitHub Pages Endpoint.
jobs:
delivery:
name: Build & Deploy
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Execution Environment for Node
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- name: Cache Node Modules
id: node_modules_cache_id
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.os }}-node-v${{ env.NODE_VERSION }}-deps-${{ hashFiles(format('{0}{1}', github.workspace, '/yarn.lock')) }}
restore-keys: |
${{ runner.os }}-node-v${{ env.NODE_VERSION }}-deps-
- name: Install Dependencies
run: yarn
- name: Do Build
if: env.LAUNCH_BUILD == 'on'
run: yarn build
- name: Clean Delivery Directory
if: env.LAUNCH_DEPLOY == 'on'
run: rm delivery/.gitkeep
- name: Deploy FTP
if: env.LAUNCH_DEPLOY == 'on' && env.DEPLOY_TYPE == 'ftp'
uses: SamKirkland/FTP-Deploy-Action@4
with:
server: ${{ secrets.FTP_SERVER }}
username: ${{ secrets.FTP_USER }}
password: ${{ secrets.FTP_PASSWORD }}
local-dir: delivery/
server-dir: ${{ secrets.FTP_REMOTE_ROOT }}
- name: Deploy to Product Branch
if: env.LAUNCH_DEPLOY == 'on'
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: product
publish_dir: ./delivery
- name: Preparation for Copy to Main Branch
if: env.LAUNCH_DEPLOY == 'on'
run: npx rimraf delivery/* && touch delivery/.gitkeep
- name: Copy to Main Branch
if: env.LAUNCH_DEPLOY == 'on'
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: main
publish_dir: ./
report:
name: Done's Report
needs: delivery
runs-on: ubuntu-latest
steps:
- name: Finished GitHub Pages Deploy
if: env.LAUNCH_DEPLOY == 'on' && env.DEPLOY_TYPE == 'github-pages' && env.ENDPOINT_GITHUB_PAGES != null
run: echo ${{ env.ENDPOINT_GITHUB_PAGES }}
- name: Finished Netlify Deploy
if: env.LAUNCH_DEPLOY == 'on' && env.DEPLOY_TYPE == 'netlify' && env.ENDPOINT_NETLIFY != null
run: echo ${{ env.ENDPOINT_NETLIFY }}
- name: Finished FTP Deploy
if: env.LAUNCH_DEPLOY == 'on' && env.DEPLOY_TYPE == 'ftp' && env.ENDPOINT_FTP != null
run: echo ${{ env.ENDPOINT_FTP }}