Skip to content

Commit b5257de

Browse files
authored
MRG: Merge pull request #4 from octue/enhancement/use-github-action-output
Use GitHub action output
2 parents 8a1a3c1 + 09c9077 commit b5257de

File tree

7 files changed

+34
-50
lines changed

7 files changed

+34
-50
lines changed

.github/workflows/release.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ jobs:
2626
uses: snok/install-poetry@v1
2727

2828
- name: Get package version
29-
run: echo "PACKAGE_VERSION=$(poetry version -s)" >> $GITHUB_ENV
29+
id: get-package-version
30+
run: echo "PACKAGE_VERSION=$(poetry version -s)" >> $GITHUB_OUTPUT
3031

3132
- name: Install tox
3233
run: pip install tox
@@ -35,14 +36,13 @@ jobs:
3536
run: tox
3637

3738
- name: Upload coverage to Codecov
38-
uses: codecov/codecov-action@v1
39+
uses: codecov/codecov-action@v3
3940
with:
40-
file: coverage.xml
41+
files: coverage.xml
4142
fail_ci_if_error: false
42-
token: ${{ secrets.CODECOV_TOKEN }}
4343

4444
outputs:
45-
package_version: ${{ env.PACKAGE_VERSION }}
45+
package_version: ${{ steps.get-package-version.outputs.PACKAGE_VERSION }}
4646

4747
release:
4848
runs-on: ubuntu-latest

.github/workflows/update-pull-request.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@ jobs:
2020
- uses: actions/checkout@v3
2121

2222
- uses: octue/generate-pull-request-description@main
23+
id: pull-request-description
2324
with:
2425
pull_request_url: ${{ github.event.pull_request.url }}
2526
api_token: ${{ secrets.GITHUB_TOKEN }}
2627

2728
- name: Update pull request body
2829
uses: riskledger/update-pr-description@v2
2930
with:
30-
body: ${{ env.PULL_REQUEST_DESCRIPTION }}
31+
body: ${{ steps.pull-request-description.outputs.pull_request_description }}
3132
token: ${{ secrets.GITHUB_TOKEN }}

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ FROM python:3.10.7-slim
22

33
RUN apt-get update && apt-get install -y --no-install-recommends git && rm -rf /var/lib/apt/lists/*
44

5-
RUN pip3 install git+https://github.com/octue/[email protected]0
5+
RUN pip3 install git+https://github.com/octue/[email protected]2
66

77
COPY generate_pull_request_description/entrypoint.sh /entrypoint.sh
88

README.md

Lines changed: 12 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4,63 +4,39 @@
44
[![black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)
55

66
# Pull request description generator
7-
A GitHub action and command-line tool that generates pull request descriptions from Conventional Commit messages on a
8-
branch. These descriptions can be used with other GitHub actions to automate release notes.
7+
A GitHub action that generates pull request descriptions from
8+
[Conventional Commit messages](https://www.conventionalcommits.org/en/v1.0.0/) on a branch. These descriptions can be
9+
used with other GitHub actions to automate release notes.
910

10-
**Features**
11+
**Features summary**
1112
- Automatic breaking change highlighting and upgrade instructions
1213
- Automatic categorisation of all commit messages in the pull request branch
1314
- Choosing which part of the description to generate, enabling descriptions containing a generated section alongside
14-
static/developer-written sections
15+
static/user-written sections
1516
- Easy skipping of description updating when you're ready to fine-tune and edit the description
1617

17-
## GitHub action
18-
The generator can easily be used as a step in a GitHub workflow alongside the
19-
[`riskledger/update-pr-description`](https://github.com/riskledger/update-pr-description) action:
18+
## Usage
19+
Add the action to pull request workflows alongside the
20+
[`riskledger/update-pr-description`](https://github.com/riskledger/update-pr-description) action to dynamically update
21+
the description each time you push:
2022

2123
```yaml
2224
steps:
2325
- uses: actions/checkout@v3
2426

25-
- uses: octue/[email protected]
27+
- uses: octue/[email protected]
28+
id: pr-description
2629
with:
2730
pull_request_url: ${{ github.event.pull_request.url }}
2831
api_token: ${{ secrets.GITHUB_TOKEN }}
2932

3033
- name: Update pull request body
3134
uses: riskledger/update-pr-description@v2
3235
with:
33-
body: ${{ env.PULL_REQUEST_DESCRIPTION }}
36+
body: ${{ steps.pr-description.outputs.pull_request_description }}
3437
token: ${{ secrets.GITHUB_TOKEN }}
3538
```
3639
37-
The generated description is available from the environment variable `PULL_REQUEST_DESCRIPTION` instead of as an output
38-
of the action (`::set-output...` only works with single-line outputs). It's accessible from
39-
`${{ env.PULL_REQUEST_DESCRIPTION }}` at any point in the workflow job it was used in.
40-
41-
## CLI
42-
```shell
43-
usage: generate-pull-request-description [-h] [--pull-request-url PULL_REQUEST_URL] [--api-token API_TOKEN] [--header HEADER] [--list-item-symbol LIST_ITEM_SYMBOL] [--no-link-to-pull-request] {LAST_RELEASE,PULL_REQUEST_START}
44-
45-
positional arguments:
46-
{LAST_RELEASE,PULL_REQUEST_START}
47-
The point in the git history to stop compiling commits into the pull request description.
48-
49-
options:
50-
-h, --help show this help message and exit
51-
--pull-request-url PULL_REQUEST_URL
52-
Provide the API URL of a pull request (e.g. https://api.github.com/repos/octue/conventional-commits/pulls/1) if you want to update a pull request's description with the generated release notes. It must be
53-
provided alongside --api-token if the repository is private.
54-
--api-token API_TOKEN
55-
A valid GitHub API token for the repository the pull request belongs to. There is no need to provide this if the repository is public.
56-
--header HEADER The header (including MarkDown styling) to put the release notes under. Default is '# Contents'
57-
--list-item-symbol LIST_ITEM_SYMBOL
58-
The MarkDown list item symbol to use for listing commit messages in the release notes. Default is '- '
59-
--no-link-to-pull-request
60-
If provided, don't add a link to the given pull request in the release notes.
61-
62-
```
63-
6440
## Features
6541
6642
### Breaking change highlighting

action.yaml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
name: 'Generate release notes'
2-
description: "Generate release notes from the Conventional Commits on a pull request branch. You can use this action in conjunction with `riskledger/update-pr-description@v2` to automatically update a pull request's description as commits are pushed."
1+
name: 'Generate pull request description'
2+
description: "Dynamically generate the pull request description for a branch from its commit messages."
33
author: 'cortadocodes'
4+
branding:
5+
icon: git-pull-request
6+
color: green
47
inputs:
58
pull_request_url:
69
description: 'The GitHub API URL for the pull request to generate the release notes from. This can be obtained from the GitHub actions environment.'
@@ -16,9 +19,13 @@ inputs:
1619
description: 'The MarkDown list item symbol to use for listing commit messages in the release notes.'
1720
required: false
1821
default: '-'
22+
outputs:
23+
pull_request_description:
24+
description: 'The generated pull request description.'
25+
1926
runs:
2027
using: 'docker'
21-
image: 'docker://octue/generate-pull-request-description:1.0.0.beta-0'
28+
image: 'docker://octue/generate-pull-request-description:1.0.0.beta-2'
2229
args:
2330
- ${{ inputs.pull_request_url }}
2431
- ${{ inputs.api_token }}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/sh -l
22
cd $GITHUB_WORKSPACE
33

4-
echo 'PULL_REQUEST_DESCRIPTION<<EOF' >> $GITHUB_ENV
5-
echo "$(generate-pull-request-description PULL_REQUEST_START --pull-request-url="$1" --api-token="$2" --header="$3" --list-item-symbol="$4")" >> $GITHUB_ENV
6-
echo EOF >> $GITHUB_ENV
4+
echo 'pull_request_description<<EOF' >> $GITHUB_OUTPUT
5+
echo "$(generate-pull-request-description PULL_REQUEST_START --pull-request-url="$1" --api-token="$2" --header="$3" --list-item-symbol="$4")" >> $GITHUB_OUTPUT
6+
echo EOF >> $GITHUB_OUTPUT

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "generate-pull-request-description"
3-
version = "1.0.0.beta-1"
3+
version = "1.0.0.beta-2"
44
description = "A GitHub action that summarises the commits in a pull request for its description."
55
authors = ["Marcus Lugg <[email protected]>"]
66
readme = "README.md"

0 commit comments

Comments
 (0)