Repository navigation
Expand file tree
/
Copy pathaction.yml
More file actions
164 lines (151 loc) · 5.76 KB
/
Copy pathaction.yml
File metadata and controls
164 lines (151 loc) · 5.76 KB
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
name: "Frappe Deployer Action"
description: "Deploy Frappe using frappe-deployer"
branding:
icon: "upload-cloud"
color: "blue"
inputs:
command:
description: "Command to run (pull or ship)"
required: false
default: "pull"
# --- Identity (required for both modes) ---
gh_token:
description: "GitHub token for private repo access"
required: true
ssh_private_key:
description: "SSH private key for remote server access (both modes)"
required: true
ssh_server:
description: "SSH server hostname or IP (leave empty to read from [ship].host in TOML config)"
required: false
ssh_user:
description: "SSH username on remote server (leave empty to read from [ship].ssh_user in TOML config, defaults to 'frappe')"
required: false
ssh_port:
description: "SSH port for remote server"
required: false
default: "22"
# --- Config (mutually exclusive, validated in bash) ---
config_path:
description: "Path to base TOML config from repo root"
required: false
config_content:
description: "Full TOML config as inline string (alternative to config_path)"
required: false
config_overrides:
description: |
TOML fragment merged on top of config_path/config_content.
Use for environment-specific values: site_name, secrets, site_config keys.
Values here take precedence over the base config.
Example:
site_name = "mysite.example.com"
[fc]
api_key = "your-fc-api-key"
required: false
# --- Pull-only inputs ---
sitename:
description: "Site name (pull mode only)"
required: false
# --- Ship-only inputs ---
existing_release:
description: "Re-use existing local release instead of building new one. Format: release_YYYYMMDD_HHMMSS"
required: false
skip_rsync:
description: "Skip rsync step (useful when release already on remote server)"
required: false
default: "false"
# --- Switch behavior (both modes) ---
drain_workers:
description: "Drain workers before restart (overrides TOML config if specified)"
required: false
migrate:
description: "Run bench migrate after switch (overrides TOML config if specified)"
required: false
migrate_timeout:
description: "Timeout in seconds for bench migrate (overrides TOML config if specified)"
required: false
maintenance_mode:
description: "Enable maintenance mode during deploy (overrides TOML config if specified)"
required: false
maintenance_mode_phases:
description: "Maintenance mode phases: space-separated list (e.g., 'drain migrate' or 'migrate'). Overrides TOML config if specified."
required: false
backups:
description: "Take DB backup before switch (overrides TOML config if specified)"
required: false
rollback:
description: "Roll back to previous release on failure (overrides TOML config if specified)"
required: false
outputs:
release_id:
description: "Release identifier created by ship mode (release_YYYYMMDD_HHMMSS)"
value: ${{ steps.deploy.outputs.release_id }}
deployment_status:
description: "Deployment status: success or failure"
value: ${{ steps.deploy.outputs.deployment_status }}
runs:
using: "composite"
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Create temporary directory
id: temp_dir
shell: bash
run: echo "path=$(mktemp -d -p $RUNNER_TEMP)" >> $GITHUB_OUTPUT
- name: Install uv
shell: bash
run: |
mkdir -p ${{ steps.temp_dir.outputs.path }}/.bin
export UV_INSTALL_DIR=${{ steps.temp_dir.outputs.path }}/.bin
curl -LsSf https://astral.sh/uv/install.sh | sh
echo "${{ steps.temp_dir.outputs.path }}/.bin" >> $GITHUB_PATH
- name: Install frappe-deployer
shell: bash
working-directory: ${{ steps.temp_dir.outputs.path }}
run: |
uv venv --python 3.13
uv pip install ${{ github.action_path }}
- name: Run frappe-deployer
id: deploy
shell: bash
working-directory: ${{ steps.temp_dir.outputs.path }}
run: |
source .venv/bin/activate && ${{ github.action_path }}/scripts/deploy.sh
env:
CI: true
GIT_CONFIG_COUNT: 1
GIT_CONFIG_KEY_0: url.https://x-access-token:${{ inputs.gh_token }}@github.com/.insteadOf
GIT_CONFIG_VALUE_0: https://github.com/
INPUT_COMMAND: ${{ inputs.command }}
INPUT_SITENAME: ${{ inputs.sitename }}
INPUT_DRAIN_WORKERS: ${{ inputs.drain_workers }}
INPUT_MIGRATE: ${{ inputs.migrate }}
INPUT_MIGRATE_TIMEOUT: ${{ inputs.migrate_timeout }}
INPUT_MAINTENANCE_MODE: ${{ inputs.maintenance_mode }}
INPUT_MAINTENANCE_MODE_PHASES: ${{ inputs.maintenance_mode_phases }}
INPUT_BACKUPS: ${{ inputs.backups }}
INPUT_ROLLBACK: ${{ inputs.rollback }}
INPUT_EXISTING_RELEASE: ${{ inputs.existing_release }}
INPUT_SKIP_RSYNC: ${{ inputs.skip_rsync }}
SSH_PRIVATE_KEY: ${{ inputs.ssh_private_key }}
SSH_SERVER: ${{ inputs.ssh_server }}
SSH_USER: ${{ inputs.ssh_user }}
SSH_PORT: ${{ inputs.ssh_port }}
FMD_CONFIG_PATH: ${{ inputs.config_path }}
FMD_CONFIG_CONTENT: ${{ inputs.config_content }}
FMD_CONFIG_OVERRIDES: ${{ inputs.config_overrides }}
FMD_GITHUB_TOKEN: ${{ inputs.gh_token }}
FMD_ACTION_PATH: ${{ github.action_path }}
FMD_ACTION_REF: ${{ github.action_ref }}
FMD_TEMP_DIR: ${{ steps.temp_dir.outputs.path }}
- name: Upload logs on failure
if: failure()
uses: actions/upload-artifact@v7
with:
name: fmd-logs-${{ github.sha }}
path: ${{ env.FMD_LOG_DIR }}
if-no-files-found: ignore
- name: Clean up temporary directory
if: always()
shell: bash
run: rm -rf ${{ steps.temp_dir.outputs.path }}