-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
97 lines (82 loc) · 3.06 KB
/
action.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
name: 'Setup WP-ENV'
description: 'Runs wp-env to setup a WordPress site for testing.'
branding:
icon: code
color: gray-dark
inputs:
core:
description: 'The WordPress installation to use.'
phpVersion:
description: 'The PHP version to use.'
plugins:
description: 'A list of plugins to install and activate in the environment.'
themes:
description: 'A list of themes to install in the environment.'
config:
description: 'Mapping of wp-config.php constants to their desired values.'
mappings:
description: 'Mapping of WordPress directories to local directories to be mounted in the WordPress instance.'
env:
description: 'Override any of the above options on an individual-environment basis.'
default: '{}'
runs:
using: 'composite'
steps:
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 'lts/*'
- name: Install wp-env
shell: bash
run: npm -g i @wordpress/env
# Although @wordpress/env ships with a default configuration, a missing or
# empty .wp-env.json or .wp-env.override.json file will throw a warning. We
# provide a minimum config which includes only an empty env object, that can
# be overridden with the Action's env input.
- name: Create the configuration file
shell: bash
run: |
WP_ENV_CONFIG=$(jq -cnr '{ "env" : ${{ inputs.env }} }')
echo "WP_ENV_CONFIG=$WP_ENV_CONFIG" >> $GITHUB_ENV
- name: Set the WordPress version
if: ${{ '' != inputs.core }}
shell: bash
run: |
WP_ENV_CONFIG=$(jq -cr '.core = "${{ inputs.core }}"' <<< "$WP_ENV_CONFIG")
echo "WP_ENV_CONFIG=$WP_ENV_CONFIG" >> $GITHUB_ENV
- name: Set the PHP version
if: ${{ '' != inputs.phpVersion }}
shell: bash
run: |
WP_ENV_CONFIG=$(jq -cr '.phpVersion = "${{ inputs.phpVersion }}"' <<< "$WP_ENV_CONFIG")
echo "WP_ENV_CONFIG=$WP_ENV_CONFIG" >> $GITHUB_ENV
- name: Set the plugins
if: ${{ '' != inputs.plugins }}
shell: bash
run: |
WP_ENV_CONFIG=$(jq -cr '.plugins = ${{ inputs.plugins }}' <<< "$WP_ENV_CONFIG")
echo "WP_ENV_CONFIG=$WP_ENV_CONFIG" >> $GITHUB_ENV
- name: Set the themes
if: ${{ '' != inputs.themes }}
shell: bash
run: |
WP_ENV_CONFIG=$(jq -cr '.themes = ${{ inputs.themes }}' <<< "$WP_ENV_CONFIG")
echo "WP_ENV_CONFIG=$WP_ENV_CONFIG" >> $GITHUB_ENV
- name: Set the config
if: ${{ '' != inputs.config }}
shell: bash
run: |
WP_ENV_CONFIG=$(jq -cr '.config = ${{ inputs.config }}' <<< "$WP_ENV_CONFIG")
echo "WP_ENV_CONFIG=$WP_ENV_CONFIG" >> $GITHUB_ENV
- name: Set the mappings
if: ${{ '' != inputs.mappings }}
shell: bash
run: |
WP_ENV_CONFIG=$(jq -cr '.mappings = ${{ inputs.mappings }}' <<< "$WP_ENV_CONFIG")
echo "WP_ENV_CONFIG=$WP_ENV_CONFIG" >> $GITHUB_ENV
- name: Create .wp-env.override.json
shell: bash
run: jq -c . > .wp-env.override.json <<< "$WP_ENV_CONFIG"
- name: Start wp-env
shell: bash
run: wp-env start