Five new APIs to facilitate docbot Development #6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Check Pull Request | |
on: | |
pull_request: | |
types: [created, edited, synchronize] | |
jobs: | |
pull_request_is_valid: | |
env: | |
ISSUE_KEY: API | |
INVALID_LABEL: missing-jira-key | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
# Check if the label is not assigned and assign it then. | |
- uses: actions-ecosystem/action-add-labels@v1 | |
if: ${{ contains(github.event.pull_request.title, format('{0}-', env.ISSUE_KEY)) != true && contains( github.event.pull_request.labels.*.name, env.INVALID_LABEL) != true }} | |
with: | |
labels: ${{ env.INVALID_LABEL }} | |
# Create invalid PR comment | |
- uses: actions-ecosystem/action-create-comment@v1 | |
if: ${{ contains(github.event.pull_request.title, format('{0}-', env.ISSUE_KEY)) != true && contains( github.event.pull_request.labels.*.name, env.INVALID_LABEL) }} | |
with: | |
github_token: ${{ secrets.github_token }} | |
body: | | |
Hello, @${{ github.actor }}, It still seems that your Pull Request Title does not contain a Jira Issue Key e.g. "${{ format('{0}-596', env.ISSUE_KEY) }}". | |
To ensure transparency and security we require users to create Jira Issues and link them to Pull Requests. Please edit your title to include the appropriate Issue Key else we are not able to merge your pull request. | |
If you do not have created a Jira Issue yet, feel free to do so here: https://tosdr.atlassian.net/browse/API. | |
In case you do not want to create an account at Atlassian, feel free to pick up an existing issue on Jira and start development on it! | |
# Create invalid PR comment | |
- uses: actions-ecosystem/action-create-comment@v1 | |
if: ${{ contains(github.event.pull_request.title, format('{0}-', env.ISSUE_KEY)) != true && contains( github.event.pull_request.labels.*.name, env.INVALID_LABEL) != true }} | |
with: | |
github_token: ${{ secrets.github_token }} | |
body: | | |
Hello, @${{ github.actor }}, Thanks for contributing to the API however it seems that your Pull Request Title does not contain a Jira Issue Key e.g. "${{ format('{0}-596', env.ISSUE_KEY) }}". | |
To ensure transparency and security we require users to create Jira Issues and link them to Pull Requests. Please edit your title to include the appropriate Issue Key else we are not able to merge your pull request. | |
If you do not have created a Jira Issue yet, feel free to do so here: https://tosdr.atlassian.net/browse/API. | |
In case you do not want to create an account at Atlassian, feel free to pick up an existing issue on Jira and start development on it! | |
# Check if label exists then remove it | |
- uses: actions-ecosystem/action-remove-labels@v1 | |
if: ${{ contains(github.event.pull_request.title, format('{0}-', env.ISSUE_KEY)) && contains( github.event.pull_request.labels.*.name, env.INVALID_LABEL) }} | |
with: | |
github_token: ${{ secrets.github_token }} | |
labels: ${{ env.INVALID_LABEL }} | |
# Tell author that PR is valid again. | |
- uses: actions-ecosystem/action-create-comment@v1 | |
if: ${{ contains(github.event.pull_request.title, format('{0}-', env.ISSUE_KEY)) && contains( github.event.pull_request.labels.*.name, env.INVALID_LABEL) }} | |
with: | |
github_token: ${{ secrets.github_token }} | |
body: | | |
Hello, @${{ github.actor }}, Thanks for fixing your Pull Request Title | |
A maintainer will take a look at your Pull Request soon! | |
**Note to maintainer: When merging the Pull request, please include the Jira Issue Key in the commit message!** | |
- name: Fail PR | |
if: ${{ contains(github.event.pull_request.title, format('{0}-', env.ISSUE_KEY)) != true }} | |
run: exit 1 |