10up/action-wordpress-plugin-deploy 项目教程
1. 项目的目录结构及介绍
action-wordpress-plugin-deploy/
├── .github/
│ └── workflows/
│ └── deploy.yml
├── examples/
│ └── example-workflow.yml
├── CHANGELOG.md
├── CONTRIBUTING.md
├── CREDITS.md
├── LICENSE
├── README.md
├── action.yml
├── deploy.sh
└── distignore
目录结构介绍
- .github/workflows/: 包含GitHub Actions的工作流配置文件,通常用于自动化部署。
- examples/: 包含示例工作流文件,帮助用户快速上手。
- CHANGELOG.md: 记录项目的变更日志。
- CONTRIBUTING.md: 提供贡献指南,帮助开发者参与项目。
- CREDITS.md: 列出项目的贡献者。
- LICENSE: 项目的开源许可证。
- README.md: 项目的介绍和使用说明。
- action.yml: GitHub Action的配置文件,定义了Action的输入、输出和运行环境。
- deploy.sh: 部署脚本,用于执行实际的部署操作。
- distignore: 用于指定在部署过程中需要忽略的文件和目录。
2. 项目的启动文件介绍
action.yml
action.yml
是GitHub Action的核心配置文件,定义了Action的输入、输出和运行环境。以下是该文件的主要内容:
name: 'WordPress Plugin Deploy'
description: 'Deploy your plugin to the WordPress.org repository using GitHub Actions'
inputs:
generate-zip:
description: 'Generate a ZIP file from the SVN trunk directory'
required: false
default: 'false'
dry-run:
description: 'Set this to true if you want to skip the final Subversion commit step'
required: false
default: 'false'
outputs:
zip-path:
description: 'The path to the ZIP file generated if generate-zip is set to true'
runs:
using: 'docker'
image: 'Dockerfile'
args:
- ${{ inputs.generate-zip }}
- ${{ inputs.dry-run }}
启动文件介绍
- name: 定义Action的名称。
- description: 提供Action的简要描述。
- inputs: 定义Action的输入参数,如
generate-zip
和dry-run
。 - outputs: 定义Action的输出参数,如
zip-path
。 - runs: 指定Action的运行方式,这里是使用Docker容器运行。
3. 项目的配置文件介绍
.github/workflows/deploy.yml
deploy.yml
是GitHub Actions的工作流配置文件,定义了触发条件和执行步骤。以下是该文件的主要内容:
name: Deploy WordPress Plugin
on:
push:
tags:
- 'v*'
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Deploy Plugin
uses: 10up/action-wordpress-plugin-deploy@master
env:
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
配置文件介绍
- name: 定义工作流的名称。
- on: 定义触发工作流的条件,这里是当有新的tag被推送时触发。
- jobs: 定义工作流中的任务。
- deploy: 任务的名称。
- runs-on: 指定任务运行的环境,这里是
ubuntu-latest
。 - steps: 定义任务的具体步骤。
- uses: 指定使用的Action,这里是
10up/action-wordpress-plugin-deploy
。 - env: 定义环境变量,如
SVN_USERNAME
和SVN_PASSWORD
,这些变量通常存储在GitHub Secrets中。
- uses: 指定使用的Action,这里是
通过以上配置,用户可以自动化地将WordPress插件部署到WordPress.org的插件仓库中。