octue / generate-pull-request-description

A GitHub action that updates PR descriptions from Conventional Commits
9 stars 7 forks source link

Use github actions outputs, not `env` #3

Closed thclark closed 1 year ago

thclark commented 1 year ago

Feature request

Use Case

We want to be able to reuse the text output in subsequent jobs or reusable workflows

Current state

Current usage instructions look like this:

- uses: octue/generate-pull-request-description@1.0.0.beta-0
  with:
    pull_request_url: ${{ github.event.pull_request.url }}
    api_token: ${{ secrets.GITHUB_TOKEN }}

- name: Update pull request body
  uses: riskledger/update-pr-description@v2
  with:
    body: ${{ env.PULL_REQUEST_DESCRIPTION }}
    token: ${{ secrets.GITHUB_TOKEN }}

What's happening is that the action is putting outputs into the github actions environment, visible to all subsequent actions but not usable in subsequent jobs. This comes from before GitHub had a way of dealing with outputs.

GitHub actions now allows steps to run complex commands, including setting outputs which can then be reused in subsequent jobs (only the subsequent jobs where you want them) and reusable workflows like this.

Suggested action

Alter the outputs to be set via command rather than attached to env, update usage instructions accordingly.

cortadocodes commented 1 year ago

::set-output... only seems to work on a single line output. I attempted to use it for this action but it turns out it's very difficult for multi-line outputs (the pull request description has many lines). There are supposed workarounds but I couldn't get any of them working. Do you know of a good way to get around this?

cortadocodes commented 1 year ago

@thclark some useful info about changes in setting outputs from GitHub 2 days ago: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/

cortadocodes commented 1 year ago

I'm now able to do this because of the changes GitHub has made 🥳