Skip to content

Commit dae7bd0

Browse files
authored
Merge pull request #143 from 10up/add/examples
Add/examples
2 parents 977dc0c + a045c51 commit dae7bd0

4 files changed

Lines changed: 159 additions & 63 deletions

README.md

Lines changed: 6 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -71,70 +71,13 @@ If there are files or directories to be excluded from deployment, such as tests
7171

7272
## Example Workflow Files
7373

74-
To get started, you will want to copy the contents of one of these examples into `.github/workflows/deploy.yml` and push that to your repository. You are welcome to name the file something else, but it must be in that directory. The usage of `ubuntu-latest` is recommended for compatibility with required dependencies in this Action.
75-
76-
### Deploy on pushing a new tag
77-
78-
```yml
79-
name: Deploy to WordPress.org
80-
on:
81-
push:
82-
tags:
83-
- "*"
84-
jobs:
85-
tag:
86-
name: New tag
87-
runs-on: ubuntu-latest
88-
steps:
89-
- uses: actions/checkout@master
90-
- name: Build # Remove or modify this step as needed
91-
run: |
92-
npm install
93-
npm run build
94-
- name: WordPress Plugin Deploy
95-
uses: 10up/action-wordpress-plugin-deploy@stable
96-
env:
97-
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
98-
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
99-
SLUG: my-super-cool-plugin # optional, remove if GitHub repo name matches SVN slug, including capitalization
100-
```
74+
To get started, you will want to copy the contents of one of [these examples](examples) into `.github/workflows/deploy.yml` and push that to your repository. You are welcome to name the file something else, but it must be in that directory. The usage of `ubuntu-latest` is recommended for compatibility with required dependencies in this Action.
10175

102-
### Deploy on publishing a new release and attach a ZIP file to the release
103-
104-
```yml
105-
name: Deploy to WordPress.org
106-
on:
107-
release:
108-
types: [published]
109-
jobs:
110-
tag:
111-
name: New release
112-
runs-on: ubuntu-latest
113-
steps:
114-
- name: Checkout code
115-
uses: actions/checkout@v2
116-
- name: Build
117-
run: |
118-
npm install
119-
npm run build
120-
- name: WordPress Plugin Deploy
121-
id: deploy
122-
uses: 10up/action-wordpress-plugin-deploy@stable
123-
with:
124-
generate-zip: true
125-
env:
126-
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
127-
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
128-
- name: Upload release asset
129-
uses: actions/upload-release-asset@v1
130-
env:
131-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
132-
with:
133-
upload_url: ${{ github.event.release.upload_url }}
134-
asset_path: ${{ steps.deploy.outputs.zip-path }}
135-
asset_name: ${{ github.event.repository.name }}.zip
136-
asset_content_type: application/zip
137-
```
76+
Current set of example workflow files:
77+
78+
* [Deploy on publishing a new release and attach a ZIP file to the release](examples/deploy-on-publishing-a-new-release-and-attach-a-zip-file-to-the-release.yml)
79+
* [Deploy on pushing a new tag](examples/deploy-on-pushing-a-new-tag.yml)
80+
* [Deploy on pushing a new tag and create release with attached ZIP](examples/deploy-on-pushing-a-new-tag-and-create-release-with-attached-zip.yml)
13881

13982
## Contributing
14083

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# The name of the Github Action that displays in github.com/<username>/<repo>/actions
2+
name: Deploy to WordPress.org Repository
3+
4+
# Here we can define the events "on" which the action should be triggered.
5+
on:
6+
7+
# Since we want to publish new versions of our plugin, we only want this action to
8+
# run when publishing a new release.
9+
#
10+
# The released version of the plugin will then be deployed to the repository.
11+
#
12+
# This allows us to run and manage plugin releases from a single location.
13+
release:
14+
15+
# run only when a new release is published, but not when it's classified as a pre-release.
16+
types: [released]
17+
18+
# A list of jobs involved in this workflow.
19+
jobs:
20+
21+
# A unique job identifier.
22+
#
23+
# Github Actions can have multiple jobs and each can be referenced by its name.
24+
# However, we only need to run a few steps here and they can be handled in a single job.
25+
deploy_to_wp_repository:
26+
27+
# The proper name for the job being run.
28+
name: Deploy to WP.org
29+
30+
# The environment this job should run on. In the context of WordPress, ubuntu-latest is
31+
# pretty typical. Since we are only interacting with git and subversion, Ubuntu is perfect
32+
# for this.
33+
#
34+
# Github does offer other platforms if you need them: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idruns-on
35+
runs-on: ubuntu-latest
36+
37+
# Every job has a specific set of steps that it goes through to do its "work".
38+
#
39+
# Each step has a two key elements:
40+
# • Name
41+
# • a "run" command (an arbitrary CLI command to execute) OR a "uses" command that pulls in and executes a 3rd party action.
42+
steps:
43+
44+
# Most workflows begin by checking out the repository into the workflow filesystem.
45+
#
46+
# This is just like cloning a repository except it only checks out the specific commit
47+
# the job is executed for. In our case here, the commit that the release is attached to.
48+
- name: Checkout code
49+
uses: actions/checkout@v2
50+
51+
# Optional: If your plugin is using composer dependencies, we want to include them
52+
# WITHOUT the dev dependencies.
53+
- name: Build
54+
run: |
55+
npm install
56+
npm run build
57+
- name: WordPress Plugin Deploy
58+
59+
# You can add unique ids to specific steps if you want to reference their output later in the workflow.
60+
#
61+
# Here, this unique identifier lets us use the output from the action to get the zip-path later.
62+
id: deploy
63+
64+
# The use statement lets us pull in the work done by 10up to deploy the plugin to the WordPress repository.
65+
uses: 10up/action-wordpress-plugin-deploy@stable
66+
67+
# Steps can also provide arguments, so this configures 10up's action to also generate a zip file.
68+
with:
69+
generate-zip: true
70+
71+
# Steps can also set environment variables which can be configured in the Github settings for the
72+
# repository. Here, we are using action secrets SVN_USERNAME, SVN_PASSWORD, and PLUGIN_SLUG which
73+
# authenticate with WordPress and lets the action deploy our plugin to the repository.
74+
#
75+
# To learn more about setting and using secrets with Github Actions, check out: https://docs.github.com/en/actions/security-guides/encrypted-secrets?tool=webui#about-encrypted-secrets
76+
env:
77+
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
78+
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
79+
80+
# After the deploy, we also want to create a zip and upload it to the release on Github. We don't want
81+
# users to have to go to the repository to find our plugin :).
82+
- name: Upload release asset
83+
uses: actions/upload-release-asset@v1
84+
env:
85+
# Note, this is an exception to action secrets: GH_TOKEN is always available and provides access to
86+
# the current repository this action runs in.
87+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
88+
89+
with:
90+
# Get the URL for uploading assets to the current release.
91+
upload_url: ${{ github.event.release.upload_url }}
92+
93+
# Provide the path to the file generated in the previous step using the output.
94+
asset_path: ${{ steps.deploy.outputs.zip-path }}
95+
96+
# Provide what the file should be named when attached to the release (plugin-name.zip)
97+
asset_name: ${{ github.event.repository.name }}.zip
98+
99+
# Provide the file type.
100+
asset_content_type: application/zip
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Deploy and Release Plugin
2+
on:
3+
push:
4+
tags:
5+
- "*"
6+
jobs:
7+
tag:
8+
name: New tag
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v2
13+
- name: Build
14+
run: |
15+
npm install
16+
npm run build
17+
- name: WordPress Plugin Deploy
18+
id: deploy
19+
uses: 10up/action-wordpress-plugin-deploy@stable
20+
with:
21+
generate-zip: true
22+
env:
23+
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
24+
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
25+
- name: Create GitHub release
26+
uses: softprops/action-gh-release@v1
27+
with:
28+
files: ${{github.workspace}}/${{ github.event.repository.name }}.zip
29+
env:
30+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Deploy to WordPress.org
2+
on:
3+
push:
4+
tags:
5+
- "*"
6+
jobs:
7+
tag:
8+
name: New tag
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@master
12+
- name: Build # Remove or modify this step as needed
13+
run: |
14+
npm install
15+
npm run build
16+
- name: WordPress Plugin Deploy
17+
uses: 10up/action-wordpress-plugin-deploy@stable
18+
env:
19+
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
20+
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
21+
SLUG: my-super-cool-plugin # optional, remove if GitHub repo name matches SVN slug, including capitalization
22+

0 commit comments

Comments
 (0)