-
Notifications
You must be signed in to change notification settings - Fork 3
120 lines (104 loc) · 3.22 KB
/
gulp-build.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
name: Run gulp tasks
# Controls when the action will run
on:
push:
# On which branches
branches:
- dev
- prod
# On release
release:
types: [published]
# On PR
pull_request:
types:
- closed
branches:
- prod
# Variables
env:
dest_path: '/public_html/wp-content/themes/uncode-child'
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# Job name
build:
# Runner name
runs-on: ubuntu-latest
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
# with:
# ref: ${{ (github.event.release.target_commitish || github.ref_name) }}
# with:
# fetch-depth: 0
# ref: ${{ github.event.pull_request.head.ref }}
# Sets up node
- name: Use Node.js 16.x
uses: actions/setup-node@v1
with:
node-version: 16
# Build
- name: Build
run: |
npm ci
gulp build
# Commit
- name: Commit files
run: |
git config --local user.email "[email protected]"
git config --local user.name "github-actions"
git status
git add --force build/*
git status
git commit --allow-empty -m "update gulp output files"
shell: bash
# Push
- name: Push changes
uses: ad-m/github-push-action@master
with:
branch: ${{ (github.base_ref || github.ref) }}
github_token: ${{ secrets.GITHUB_TOKEN }}
# Job name
rclone-dev:
# Run after build
needs: build
# Runner name
runs-on: ubuntu-latest
if: ${{ (github.event.release.target_commitish || github.ref_name) == 'dev' }}
steps:
# Checkout to the branch to use the last (build) commit
- uses: actions/checkout@v2
with:
ref: ${{ (github.event.release.target_commitish || github.ref_name) }}
# rclone
- name: Copy files on dev
uses: wei/rclone@v1
env:
RCLONE_CONFIG_HDX_TYPE: ${{ secrets.RCLONE_CONFIG_HDX_TYPE }}
RCLONE_CONFIG_HDX_HOST: ${{ secrets.RCLONE_CONFIG_HDX_HOST }}
RCLONE_CONFIG_HDX_USER: ${{ secrets.RCLONE_CONFIG_HDX_USER_DEV }}
RCLONE_CONFIG_HDX_PASS: ${{ secrets.RCLONE_CONFIG_HDX_PASS_DEV }}
with:
args: copy build HDX:${{ env.dest_path }}
# Job name
rclone-prod:
# Run after build
needs: build
# Runner name
runs-on: ubuntu-latest
if: ${{ (github.event.release.target_commitish || github.ref_name) == 'prod' }}
steps:
# Checkout to the branch to use the last (build) commit
- uses: actions/checkout@v2
with:
ref: ${{ (github.event.release.target_commitish || github.ref_name) }}
# rclone
- name: Copy files on prod
uses: wei/rclone@v1
env:
RCLONE_CONFIG_HDX_TYPE: ${{ secrets.RCLONE_CONFIG_HDX_TYPE }}
RCLONE_CONFIG_HDX_HOST: ${{ secrets.RCLONE_CONFIG_HDX_HOST }}
RCLONE_CONFIG_HDX_USER: ${{ secrets.RCLONE_CONFIG_HDX_USER_PROD }}
RCLONE_CONFIG_HDX_PASS: ${{ secrets.RCLONE_CONFIG_HDX_PASS_PROD }}
with:
args: copy build HDX:${{ env.dest_path }}