-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
184 lines (153 loc) · 6.16 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
name: 'Build HydePHP Site'
description: 'Build and deploy the HydePHP project'
branding:
icon: 'box'
color: 'purple'
inputs:
debug:
description: 'Enable debug mode'
required: false
default: "false"
deploy-to:
# Pages option requires GitHub the "Build and deployment" source to be set to "GitHub Actions"
# You must also ensure that GITHUB_TOKEN has permission "id-token: write".
description: 'Specify what to do with the compiled site. Options are: [artifact, pages]'
required: true
default: "artifact"
upload-artifact:
description: 'Upload the compiled site as an artifact'
required: false
default: "false"
framework-version:
description: 'The framework version of HydePHP to install (only applicable when using archive install strategy)'
required: false
default: "latest"
directory:
description: 'The project root directory'
required: false
default: "."
config:
description: 'List of lines to add to the `hyde.yml` config file'
required: false
default: ""
# The following three inputs are deprecated and will be removed in v2.0. They are kept in v1.x for backward compatibility, but users are encouraged to migrate to the new `env` input.
env-site-name:
description: '[Deprecated] Set the `SITE_NAME` environment variable. Use the `env` input instead with `SITE_NAME=value`'
required: false
env-site-url:
description: '[Deprecated] Set the `SITE_URL` environment variable. Use the `env` input instead with `SITE_URL=value`'
required: false
env-torchlight-token:
description: '[Deprecated] Set the `TORCHLIGHT_TOKEN` environment variable. Use the `env` input instead with `TORCHLIGHT_TOKEN=value`'
required: false
env:
description: 'Environment variables in KEY=VALUE format (one per line)'
required: false
default: ''
outputs:
install-strategy:
description: 'The install strategy used'
value: ${{ steps.determine-install-strategy.outputs.install-strategy }}
runs:
using: "composite"
steps:
- name: Add action path to GitHub PATH
run: echo "${{ github.action_path }}/src" >> $GITHUB_PATH
shell: bash
- name: Validate input
id: validate-input
run: bash validate-input.sh ${{ inputs.deploy-to }}
shell: bash
- name: Configure root directory
id: configure-root-directory
run: bash configure-root-directory.sh ${{ inputs.directory }}
shell: bash
- name: Determine install strategy
id: determine-install-strategy
run: bash determine-install-strategy.sh
shell: bash
- name: Print debug information
if: inputs.debug == 'true'
run: |
echo "Debug mode: ${{ inputs.debug }}"
echo "Deployment option: ${{ inputs.deploy-to }}"
echo "Install strategy: ${{ steps.determine-install-strategy.outputs.install-strategy }}"
echo action_path: ${{ github.action_path }}
shell: bash
- name: Validate composer.json and composer.lock
if: steps.determine-install-strategy.outputs.install-strategy == 'composer'
run: composer validate --strict
shell: bash
- name: Cache Composer packages
id: composer-cache
if: steps.determine-install-strategy.outputs.install-strategy == 'composer'
uses: actions/cache@v4
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Download latest release
if: steps.determine-install-strategy.outputs.install-strategy == 'archive'
run: bash download-latest-release.sh ${{ inputs.framework-version }}
shell: bash
- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-autoloader && composer dump-autoload --quiet
shell: bash
- name: Set up environment variables
run: bash copy-example-environment.sh
shell: bash
# Inject environment variables
- if: inputs.env-site-name != ''
run: |
bash print-deprecation-warning.sh "env-site-name" "env: SITE_NAME=value" "$GITHUB_WORKFLOW"
echo "SITE_NAME=${{ inputs.env-site-name }}" >> .env
shell: bash
- if: inputs.env-site-url != ''
run: |
bash print-deprecation-warning.sh "env-site-url" "env: SITE_URL=value" "$GITHUB_WORKFLOW"
echo "SITE_URL=${{ inputs.env-site-url }}" >> .env
shell: bash
- if: inputs.env-torchlight-token != ''
run: |
bash print-deprecation-warning.sh "env-torchlight-token" "env: TORCHLIGHT_TOKEN=value" "$GITHUB_WORKFLOW"
echo "TORCHLIGHT_TOKEN=${{ inputs.env-torchlight-token }}" >> .env
shell: bash
- name: Set custom environment variables
if: inputs.env != ''
run: bash set-environment-variables.sh '${{ inputs.env }}'
shell: bash
- name: Set up configuration
if: inputs.config != ''
run: echo "${{ inputs.config }}" >> hyde.yml
shell: bash
- name: Check site URL configuration
run: bash check-site-url.sh
shell: bash
# TODO: Add pre-build hook to run some bash commands?
- name: Build the site
run: php hyde build --no-interaction --ansi
shell: bash
# TODO: Add post-build hook to run some bash commands?
- name: Upload artifact
if: inputs.deploy-to == 'artifact' || inputs.upload-artifact == 'true'
uses: actions/upload-artifact@v3
with:
name: build
path: _site # TODO: Get this from the config file in case it's customized
- name: Setup Pages
if: inputs.deploy-to == 'pages'
uses: actions/configure-pages@v5
- name: Upload artifact
if: inputs.deploy-to == 'pages'
uses: actions/upload-pages-artifact@v3
with:
path: _site # TODO: Get this from the config file in case it's customized
- name: Deploy to GitHub Pages
id: pages-deployment
if: inputs.deploy-to == 'pages'
uses: actions/deploy-pages@v4
# Now that the site is built, there are a few options for deployment.
# We could push directly to the gh-pages branch, commit files to /docs,
# or even use the GitHub Pages action to deploy the compiled site.
# We could also upload the site as an artifact for later use.