-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
143 lines (121 loc) · 4.72 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
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
139
140
141
142
name: 'Launch a site with DDEV'
description: 'Launches a new site using DDEV.'
inputs:
git-repository:
description: The full git URL to clone. Defaults to this repository.
default: [email protected]:${{ github.repository }}
required: false
ddev-project-name:
description: "The DDEV project name to use for this environment. Will be used in the URL."
required: false
default: "${{ github.event.repository.name }}.pr${{ github.event.number }}"
ddev-project-tld:
description: "The DDEV project's project_tld. If not specified, the global DDEV project_tld will be used."
required: false
ddev-fqdns:
description: "A list of domains to apply to this environment, separated by a comma."
required: false
ddev-start:
description: "If set to 'true', `ddev start` will be run."
default: "true"
git-reference:
description: "The git reference to checkout."
required: false
default: ${{ github.head_ref }}
path:
description: "Path to clone this environment's code to, relative to the runner's home directory."
required: false
default: "Sites/${{ github.repository }}/pr${{ github.event.number }}"
sync:
description: "If set to 'true', the environment will be destroyed and replaced with data using the 'sync-command' input."
required: false
default: "false"
composer-install-command:
description: "The command to run to prepare the codebase"
required: false
default: "ddev composer install --ansi"
sync-command:
description: "The command to run to sync the sites data. Override if source is not the @live drush alias or sql:sync command does not work for you."
required: false
default: |
ddev drush sql:sync @live @self
ddev drush rsync @live:%files %files
update-command:
description: "The command to run to update the sites data."
required: false
default: "ddev drush updatedb"
ssh-known-hosts:
description: "SSH Known Hosts"
required: false
ssh-private-key:
description: "SSH private key to use to access remote servers."
required: false
runs:
using: "composite"
steps:
- name: Set environment
shell: bash
run: |
echo "DDEV_PROJECT_PATH_FULL=$HOME/${{ inputs.path }}" >> "$GITHUB_ENV"
- name: Prepare Code
shell: bash
# Must exist. If not yet cloned, ${{env.DDEV_PROJECT_PATH}} directory will not exist.
working-directory: "/"
run: |
echo "${{ inputs.ssh-known-hosts }}" > ~/.ssh/known_hosts
if [[ ! -d ${{ env.DDEV_PROJECT_PATH_FULL }} ]]; then
git clone ${{ inputs.git-repository }} ${{env.DDEV_PROJECT_PATH_FULL}}
else
echo "Git clone exists at ${{env.DDEV_PROJECT_PATH_FULL}}"
fi
cd ${{env.DDEV_PROJECT_PATH_FULL}}
echo "Current Directory: $(pwd)"
echo "Pre-deployment git status: $(git status)"
git fetch
git checkout ${{ inputs.git-reference }}
git reset --hard origin/${{ inputs.git-reference }}
echo "Post deployment git status: $(git status)"
echo "name: ${{ inputs.ddev-project-name }}" > .ddev/config.z.yml
if [[ -n "${{ inputs.ddev-project-tld }}" ]]; then
echo "project_tld: ${{ inputs.ddev-project-tld }}" >> .ddev/config.z.yml
fi
if [[ -n "${{ inputs.ddev-fqdns }}" ]]; then
echo "additional_fqdns: [${{ inputs.ddev-fqdns }}]" >> .ddev/config.z.yml
fi
# Secrets: https://github.com/thinkdrop/thinkdrop.net/settings/secrets/actions
# To retrieve SSH_KNOWN_HOSTS string:
# ssh-keyscan -H liveserver.com -H github.com -H otherserver.com
- name: Start DDEV
if: ${{ inputs.ddev-start == 'true' }}
shell: bash
working-directory: ${{ env.DDEV_PROJECT_PATH_FULL }}
env:
DDEV_NONINTERACTIVE: "true"
run: |
ddev start
- name: Grant DDEV SSH Access
shell: bash
working-directory: ${{ env.DDEV_PROJECT_PATH_FULL }}
run: |
echo "${{ inputs.ssh-private-key }}" > ddev_id_rsa
ddev exec 'cat ddev_id_rsa > ~/.ssh/id_rsa'
ddev exec 'chmod 600 ~/.ssh/id_rsa'
if [ "${{ inputs.ssh-known-hosts }}" != "" ]; then
ddev exec 'echo "${{ inputs.ssh-known-hosts }}" > ~/.ssh/known_hosts'
fi
- name: Composer Install
shell: bash
working-directory: ${{ env.DDEV_PROJECT_PATH_FULL }}
run: |
${{ inputs.composer-install-command }}
- name: Sync
if: ${{ inputs.sync == 'true' }}
shell: bash
working-directory: ${{ env.DDEV_PROJECT_PATH_FULL }}
run: |
${{ inputs.sync-command }}
- name: Drupal Database Updates
shell: bash
working-directory: ${{ env.DDEV_PROJECT_PATH_FULL }}
run: |
${{ inputs.update-command }}