Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue ops #13

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions .github/ISSUE_TEMPLATE/wordpress-dependency.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Add or remove a WordPress theme or plugin
description: Make a pull request to add or remove a WordPress theme or plugin.
labels: ["dependencies"]

title: "[package-name]"

body:
- type: dropdown
id: action
attributes:
label: Action
description: |
The action to perform.
options:
- require
- remove
default: 0
validations:
required: true

- type: dropdown
id: repository
attributes:
label: Type of dependency
description: |
The repository to use.
options:
- wpackagist-plugin
- wpackagist-theme
default: 0
validations:
required: true
- type: input
id: package
attributes:
label: Package Slug
placeholder: my-package
validations:
required: true
- type: input
id: version
attributes:
label: Version
placeholder: 1.0.0
validations:
required: true
- type: dropdown
id: constraint
attributes:
label: Version Constraint
description: |
The constraint to use when installing the plugin. See [Composer documentation](https://getcomposer.org/doc/articles/versions.md#versions-and-constraints) for more information.
options:
- "^"
- "="
- ">="
- "<="
- "*"
default: 0
validations:
required: true
- type: checkboxes
id: changedTitle
attributes:
label: Have you changed the title of this issue?
description: |
If you have changed the title of this issue to include the plugin name, please check this box.
options:
- label: I promise I changed the title of this issue to include the plugin name.
required: true
81 changes: 81 additions & 0 deletions .github/actions/composer/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: '🐘 WordPress Packagist action'
description: 'Manipulate a WordPress Packagist dependency'

inputs:
# The action to take
action:
description: 'The action to take'
required: true
default: 'require'

# The repository to use
repository:
description: 'The repository to use'
required: true
default: '""'

# The package to install
package:
description: 'The package to install'
required: true
default: '""'

# The version to install
version:
description: 'The version to install'
required: true
default: '""'

# The version constraint to set
constraint:
description: 'The version constraint to set'
required: true
default: '""'

# The path to the composer.json file
composer_json_path:
description: 'The path to the composer.json file'
required: true
default: '""'

# The actor
actor:
description: 'The actor'
required: true
default: '""'

# Issue number
issue_number:
description: 'The issue number'
required: true
default: '""'

# GitHub token
github_token:
description: 'The GitHub token to use'
required: true

runs:
using: 'composite'
steps:

# Perform the composer action
- name: Perform the composer action
uses: php-actions/composer@v6
with:
command: |
${{ inputs.action }} ${{ inputs.repository }}/${{ inputs.package }}:${{ inputs.constraint }}${{ inputs.version }}
args: --no-interaction --no-progress --working-dir=site

# Create a pull request from the new branch to the branch specified in env
- name: Create pull request
uses: peter-evans/create-pull-request@v5
with:
token: ${{ inputs.github_token }}
add-paths: ./site/composer.json, ./site/composer.lock
commit-message: 'Plugin request from ${{ inputs.actor }}: ${{ inputs.action }} ${{ inputs.repository }}/${{ inputs.package }} ${{ inputs.version }}'
title: 'Plugin request from ${{ inputs.actor }}: ${{ inputs.action }} ${{ inputs.repository }}/${{ inputs.package }} ${{ inputs.version }}'
body: 'Closes #${{ inputs.issue_number }}'
branch: ${{ inputs.repository }}-${{ inputs.package }}-${{ inputs.version }}
base: ${{ env.environment }}
labels: 'composer, ${{ inputs.action }}, ${{ inputs.repository }}, ${{ inputs.package }}'
46 changes: 46 additions & 0 deletions .github/workflows/composer-dependency.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# .github/workflows/composer-dependency.yml
##
# Add and remove WordPress themes or plugins using Composer.
##

name: 🐘 Composer Dependency
run-name: composer-dependency

# Run when a new issue is opened
on:
issues:
types: [opened]

env:
environment: staging

jobs:
composer-plugin:
if: ${{ github.event.label.name == 'dependencies' }}
runs-on: ubuntu-latest
steps:
# Checkout the repo's staging branch.
- uses: actions/checkout@v3
with:
ref: ${{ env.environment }}
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo

# Parse the issue
- uses: stefanbuck/github-issue-parser@v3
id: issue-parser
with:
template-path: ./.github/ISSUE_TEMPLATE/plugin.yml

# Install or remove WordPress plugins using Composer
- uses: ./.github/actions/composer
name: Composer Action
with:
action: ${{ steps.issue-parser.outputs.issueparser_action }}
repository: ${{ steps.issue-parser.outputs.issueparser_repository }}
package: ${{ steps.issue-parser.outputs.issueparser_package }}
version: ${{ steps.issue-parser.outputs.issueparser_version }}
constraint: ${{ steps.issue-parser.outputs.issueparser_constraint }}
composer_json_path: ./site/composer.json
actor: ${{ github.actor }}
issue_number: ${{ github.event.issue.number }}
github_token: ${{ secrets.GITHUB_TOKEN }}
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Automatically deploy your [Trellis](https://roots.io/trellis/)-based WordPress s
- 🔑 **Re-set deployment keys on-demand** when you need to change who has access to `staging` or `production`.
- 📦 **WordPress plugin, core, and theme updates** managed with [Dependabot](https://docs.github.com/en/code-security/supply-chain-security/keeping-your-dependencies-updated-automatically/about-dependabot-version-updates).
- 📝 **Optionally generates README.md** with deployment status badges and setup instructions.
- 🚩 **Manage WordPress Dependencies** with issue-ops. Install or remove plugins and themes by submitting a GitHub issue.

### Optional Additional Workflows

Expand Down Expand Up @@ -114,6 +115,15 @@ This action replaces the current deploy keys with keys with keys defined in one

Updates the README.md with the current deployment status badges. This action can be run manually from the "Actions" tab in GitHub.
</details>
<details>
<summary>🐘 Composer Dependency</summary>

```md
.github/workflows/composer-dependency.yml
```

Generates a pull request against the `staging` branch to install a WordPress theme or plugin via composer. This action runs when a new ticket is submitted that uses the "wordpress-dependency.yml" template.
</details>

### Optional Workflows

Expand Down