Skip to content

Update pipeline-steps-f8e69f4.md #9

Update pipeline-steps-f8e69f4.md

Update pipeline-steps-f8e69f4.md #9

name: Merged pull request labeler
# What the execution context is:
# The merging (not just closing) of a pull request.
# What it does:
# Assigns the 'valuable contribution' label.
# Why we need it:
# To mark a valuable pull request contribution, and thus to cause the
# SAP Community profile URL requester to be triggered.
# What's important to know:
# The label to assign is defined at the start of the job, in the LABEL
# environment variable. The label is not assigned if the actor is an administrator.
on:
pull_request_target:
types: [closed]
jobs:
assign-label-on-merge:
if: contains(github.repositoryUrl, 'github.com') && github.event.pull_request.merged
env:
LABEL: "contribution"
runs-on: ubuntu-20.04
steps:
- id: token_gen
name: Generate app installation token
uses: machine-learning-apps/actions-app-token@0.21
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: auth_gh
name: Authenticate gh to repo
run: echo -n ${{ steps.token_gen.outputs.app_token }} | gh auth login --with-token
- id: determine_permission
name: Look up repository permission level for PR author
run: |
pr_author="$(gh api --jq .user.login "${{ github.event.pull_request._links.self.href }}")"
permission="$(gh api --jq .permission "/repos/$GITHUB_REPOSITORY/collaborators/$pr_author/permission")"
echo "pr_author=$pr_author"
echo "repo_permission=$permission" | tee --append "$GITHUB_ENV"
- id: assign_label
if: env.repo_permission != 'admin'
run: gh pr edit ${{ github.event.number }} --add-label "$LABEL"