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

Add merge-trunk-develop-pr action #71

Merged
merged 3 commits into from
Aug 7, 2023
Merged
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
2 changes: 2 additions & 0 deletions packages/github-actions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ Custom GitHub actions that help to composite GitHub workflows across the repos m

## Actions list

- [`automerge-released-trunk`](actions/automerge-released-trunk) - Merge `trunk` to `develop` after an extension release
- [`branch-label`](actions/branch-label) - Set PR labels according to the branch name
- [`coverage-report`](actions/coverage-report) - Add a clover coverage report as a PR comment
- [`eslint-annotation`](actions/eslint-annotation) - Annotate eslint results via eslint formatter
- [`get-plugin-releases`](actions/get-plugin-releases) - Get latest releases versions from WordPress or from a plugin.
- [`get-release-notes`](actions/get-release-notes) - Get release notes via GitHub, infer the next version and tag
- [`hook-documentation`](actions/hook-documentation) - Generate WordPress hook documentation
- [`merge-trunk-develop-pr`](actions/merge-trunk-develop-pr) - Create a PR to merge `trunk` to `develop` after an extension release
- [`phpcs-diff`](actions/phpcs-diff) - Run PHPCS to the changed lines of code, set error annotations to a pull request
- [`prepare-extension-release`](actions/prepare-extension-release) - Create the release branch & PR with checklist
- [`prepare-mysql`](actions/prepare-mysql) - Enable MySQL, handle authentication compatibility
Expand Down
28 changes: 28 additions & 0 deletions packages/github-actions/actions/merge-trunk-develop-pr/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# PR to merge `trunk` to `develop`

This action provides the following functionality for GitHub Actions users:

- Create a PR to merge `trunk` to `develop` after a release done with the `woocommerce/grow/prepare-extension-release`

## Usage

See [action.yml](action.yml)

#### Basic:

```yaml
name: PR to merge a released trunk

on:
pull_request:
types:
- closed
branches:
- trunk

jobs:
automerge_trunk:
runs-on: ubuntu-latest
steps:
- uses: woocommerce/grow/merge-trunk-develop-pr@actions-v1
```
19 changes: 19 additions & 0 deletions packages/github-actions/actions/merge-trunk-develop-pr/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Merge `trunk` to `develop` PR
description: Create a PR to merge `trunk` to `develop` after a release

runs:
using: composite
steps:
- name: "Make the PR"
if: ${{ github.event.pull_request.merged == true && startsWith(github.head_ref, 'release/') && github.event.pull_request.user.login == 'github-actions[bot]' }}
uses: actions/github-script@v6
with:
script: |
const title = '${{github.event.pull_request.title}} - Merge `trunk` to `develop`';
const opts = await github.rest.pulls.create( {
...context.repo,
base: 'develop',
head: 'trunk',
title,
body: '${{ github.event.pull_request.html_url }}',
} );