Skip to content

Commit

Permalink
feat(.github/actions): add get-version-number-and-issue-url action
Browse files Browse the repository at this point in the history
  • Loading branch information
Zidious committed Oct 13, 2023
1 parent 96267ef commit f8ea968
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .github/actions/get-version-number-and-issue-url-v1/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# get-version-number-and-issue-url-v1

This action gets the version number and issue url from the release-candidate.

## Outputs

| Output | Description |
| ---------------- | ----------------------------------------------------------- |
| `version-number` | The version number of the release candidate. |
| `issue-url` | The url of the issue associated with the release candidate. |

## Example usage

```yaml
name: Get version number and issue url and post to Slack

on: push

jobs:
post-to-slack:
runs-on: ubuntu-latest
steps:
- name: get version number and release-candidate issue URL
- uses: dequelabs/axe-api-team-public/.github/actions/get-version-number-and-issue-url-v1@main
id: get-version-number-and-issue-url

- name: Slack Notification
# https://github.com/rtCamp/action-slack-notify/commit/b24d75fe0e728a4bf9fc42ee217caa686d141ee8
uses: rtCamp/action-slack-notify@12e36fc18b0689399306c2e0b3e0f2978b7f1ee7
env:
SLACK_CHANNEL: example-channel
SLACK_COLOR: ${{ job.status }}
SLACK_TITLE: '${{ github.event.repository.name }} v${{ steps.get-version-number-and-issue-url.outputs.version-number }} QA NEEDED'
SLACK_MESSAGE: '${{ steps.get-version-number-and-issue-url.outputs.issue-url }}'
SLACK_WEBHOOK: ${{ inputs.slack-webhook }}
MSG_MINIMAL: true
```
34 changes: 34 additions & 0 deletions .github/actions/get-version-number-and-issue-url-v1/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: get-version-number-and-issue-url
description: 'A small GitHub Action to get the version number and issue URL for a release candidate'

outputs:
version-number:
description: 'The version number for the release candidate'
value: ${{ steps.get_version_number.outputs.version-number }}
issue-url:
description: 'The issue URL for the release candidate'
value: ${{ steps.get_issue_url.outputs.issue-url }}

runs:
using: 'composite'
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
# Fetch all history
fetch-depth: 0

- name: Get release-candidate issue URL
id: get_issue_url
shell: bash
run: |
echo "issue-url=$(gh issue list --repo ${{ github.repository }} --label release --state open --json url --jq '.[0].url')" >> $GITHUB_OUTPUT
- name: Get release-candidate version number
id: get_version_number
shell: bash
run: |
pullRequestID=$(gh pr list --repo ${{ github.repository }} --json number -s merged --base release --jq '.[0].number')
# Get the version number from the pull request title e.g. 1.33.7
echo "version-number=$(gh pr view $pullRequestID --repo ${{ github.repository }} --json title --jq '.title' | grep grep -E -o '\d+.\d+.\d+' | awk '{print $NF}')" >> $GITHUB_OUTPUT

0 comments on commit f8ea968

Please sign in to comment.