mirror of
https://github.com/yanhao98/composite-actions.git
synced 2025-07-13 14:50:48 +08:00
Feat/surge customizable dirs (#49)
* feat: Allow customizing working_dir and dist_dir for Surge deployment This commit introduces two new optional inputs to the `deploy-dist-to-surge` action: - `working_dir`: Specifies the directory from which the Surge command should be run. Defaults to the repository root (`.`). - `dist_dir`: Specifies the directory containing the built assets to deploy, relative to `working_dir`. Defaults to `dist`. These changes provide more flexibility for projects where the build output is not in the default `dist` folder at the root of the repository. Updated README.md with details on the new inputs and an example usage. * feat: Allow customizing working_dir and dist_dir for Surge deployment This commit introduces two new optional inputs to the `deploy-dist-to-surge` action: - `working_dir`: Specifies the directory from which the Surge command should be run. Defaults to the repository root (`.`). - `dist_dir`: Specifies the directory containing the built assets to deploy, relative to `working_dir`. Defaults to `dist`. These changes provide more flexibility for projects where the build output is not in the default `dist` folder at the root of the repository. Updated README.md with details on the new inputs and an example usage. Also updated the test workflow `.github/workflows/deploy-dist-to-surge-tetst.yaml` to utilize and verify these new inputs. * feat: 支持唯一测试域名并更新中文描述 此提交为 `deploy-dist-to-surge` 操作引入了 `domain_suffix` 输入,以允许在同一工作流程中为多次部署生成唯一的 Surge 域名,这对于测试至关重要。 同时包含先前对 `working_dir` 和 `dist_dir` 输入的支持,并更新了 `action.yml` 和 `README.md` 中的所有相关描述为中文。 测试工作流程已更新以使用 `domain_suffix` 并验证自定义目录和默认目录的部署。 --------- Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
This commit is contained in:
@ -14,13 +14,51 @@ jobs:
|
||||
job:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: 准备部署文件
|
||||
- name: Checkout code # Required to use the local version of the action
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: 准备部署文件 (Testing working_dir and dist_dir)
|
||||
run: |
|
||||
mkdir -p test_project/build_output
|
||||
html="<!DOCTYPE html><html><body><h1>Test: ${{ github.event_name }}: ${{ github.sha }} - Custom Dirs</h1></body></html>"
|
||||
echo $html > test_project/build_output/index.html
|
||||
|
||||
- name: Deploy with custom working_dir and dist_dir
|
||||
uses: ./deploy-dist-to-surge # Use local action
|
||||
id: surge_deploy_custom
|
||||
with:
|
||||
working_dir: ./test_project
|
||||
dist_dir: build_output
|
||||
domain_suffix: -custom
|
||||
|
||||
- name: Check Surge URL (Custom Dirs)
|
||||
run: |
|
||||
echo "Custom dirs deployment URL: ${{ steps.surge_deploy_custom.outputs.url }}"
|
||||
# Add a basic check if the URL is not empty
|
||||
if [ -z "${{ steps.surge_deploy_custom.outputs.url }}" ]; then
|
||||
echo "Error: Surge URL for custom dirs is empty!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: 准备部署文件 (Testing default dist_dir)
|
||||
run: |
|
||||
mkdir dist
|
||||
html="<!DOCTYPE html><html><body><h1>${{ github.event_name }}: ${{ github.sha }}</h1></body></html>"
|
||||
html="<!DOCTYPE html><html><body><h1>Test: ${{ github.event_name }}: ${{ github.sha }} - Default Dist</h1></body></html>"
|
||||
echo $html > dist/index.html
|
||||
- uses: yanhao98/composite-actions/deploy-dist-to-surge@main
|
||||
id: surge_deploy
|
||||
- name: Check Surge URL
|
||||
|
||||
- name: Deploy with default dist_dir
|
||||
uses: ./deploy-dist-to-surge # Use local action
|
||||
id: surge_deploy_default
|
||||
with:
|
||||
domain_suffix: -default
|
||||
|
||||
- name: Check Surge URL (Default Dist)
|
||||
run: |
|
||||
echo "steps.surge_deploy.outputs.url: ${{ steps.surge_deploy.outputs.url }}"
|
||||
echo "Default dist deployment URL: ${{ steps.surge_deploy_default.outputs.url }}"
|
||||
# Add a basic check if the URL is not empty
|
||||
if [ -z "${{ steps.surge_deploy_default.outputs.url }}" ]; then
|
||||
echo "Error: Surge URL for default dist is empty!"
|
||||
exit 1
|
||||
fi
|
||||
# The following line was from the old version and is redundant as we check specific outputs above.
|
||||
# echo "steps.surge_deploy.outputs.url: ${{ steps.surge_deploy.outputs.url }}"
|
||||
|
Reference in New Issue
Block a user