Skip to content

Fix typos

Fix typos #780

name: SAP Community profile URL requester
# What the execution context is:
# The assignment of a label to an issue or pull request indicating
# that the contribution was valuable.
# What it does:
# Adds a comment to the issue or pull request asking the author for
# their SAP Community ID.
# Why we need it:
# So that we can properly recognize the contribution in SAP Community.
# What's important to know:
# The label is specified at the start of the 'community-id-requester'
# job as an environment variable LABEL, and also in the job-level condition.
# Also, it adds a comment only after the first time the label is added, and
# only if there are no other issues / pull requests already labeled.
on:
pull_request_target:
types: [labeled]
issues:
types: [labeled]
jobs:
community-id-requester:
env:
LABEL: "contribution"
runs-on: ubuntu-20.04
if: contains(github.repositoryUrl, 'github.com') && github.event.label.name == 'contribution'
steps:
- id: token_gen
name: Generate app installation token
uses: machine-learning-apps/[email protected]
with:
APP_PEM: ${{ secrets.SAP_CODOC_APP_PEM_BASE64 }}
APP_ID: ${{ secrets.SAP_CODOC_APP_ID }}
- id: checkout
name: Check out the repo
uses: actions/checkout@v3
with:
token: ${{ steps.token_gen.outputs.app_token }}
- id: issue_details
name: Determine related details if issue
if: github.event_name == 'issues'
run: |
echo "OBJECTTYPE=issue" >> $GITHUB_ENV
echo "CONTRIBUTIONTYPE=feedback" >> $GITHUB_ENV
echo "OBJECTNR=${{ github.event.issue.number }}" >> $GITHUB_ENV
echo "CONTRIBUTOR=${{ github.event.issue.user.login }}" >> $GITHUB_ENV
- id: pull_request_details
name: Determine related details if pull request
if: github.event_name == 'pull_request_target'
run: |
echo "OBJECTTYPE=pr" >> $GITHUB_ENV
echo "CONTRIBUTIONTYPE=content" >> $GITHUB_ENV
echo "OBJECTNR=${{ github.event.pull_request.number }}" >> $GITHUB_ENV
echo "CONTRIBUTOR=${{ github.event.pull_request.user.login }}" >> $GITHUB_ENV
- id: auth_gh
name: Authenticate gh to repo
run: echo -n ${{ steps.token_gen.outputs.app_token }} | gh auth login --with-token
- id: count_label_additions
name: Count number of times label has been added
run: |
endpoint="repos/${{ github.repository }}/issues/$OBJECTNR/events"
count=$(gh api --jq "[.[]|(select(.event==\"labeled\" and .label.name==\"$LABEL\"))] | length" $endpoint)
echo "LABELADDITIONCOUNT=$count" >> $GITHUB_ENV
- id: count_previous_labeled_objects
name: Count how many other issues / pull requests are so labeled
run: |
querystring="is:${OBJECTTYPE}+label:${LABEL}+author:${CONTRIBUTOR}+repo:${GITHUB_REPOSITORY}"
result=$(gh api --jq '.items[] | [.number, .title] | @tsv' "/search/issues?q=$querystring")
echo "$result"
echo "OBJECTCOUNT=$(wc -l <<< $result)" | tee -a $GITHUB_ENV
- id: requester
name: Ask for SAP Community profile URL if label added for first time and no prev labeled issue / pr
if: env.LABELADDITIONCOUNT == 1 && env.OBJECTCOUNT <= 1
run: |
printf "Thank you for your valuable ${CONTRIBUTIONTYPE} contribution, @${CONTRIBUTOR}! So that we can [recognize your contribution in the SAP Community](https://github.com/SAP-docs/contribution-guidelines/blob/main/docs/recognition.md), please check your SAP Community user ID (this is a number) in your [personal settings page](https://community.sap.com/t5/user/myprofilepage/tab/personal-profile) and share it with us in a reply to this comment. Make sure you just include the number in the reply.\n\nYour user ID is displayed as follows:\n\n**Change display name for User ID N**\n\nwhere N is your user ID. For example, [53 is the user ID of the user 'qmacro'](https://community.sap.com/t5/user/viewprofilepage/user-id/53).\n\nPlease note that we are currently refactoring our profile and badge system on the SAP Community, and will start assigning badges again when that's complete." \
| gh $OBJECTTYPE comment $OBJECTNR --body-file -