-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
33bf9b0
commit 2b15bd4
Showing
3 changed files
with
118 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/usr/bin/env bash | ||
|
||
CONFIG_URL="https://raw.githubusercontent.com/datalens-tech/datalens/main/.github/workflows/scripts/changelog/changelog_config.json" | ||
|
||
PR_TITLE=${PR_TITLE} | ||
GH_TOKEN=${GH_TOKEN} | ||
REPO=${REPO} | ||
PR_NUMBER=${PR_NUMBER} | ||
|
||
CONFIG_DATA=$(curl -s $CONFIG_URL) | ||
|
||
TYPE_LABELS=$(echo $CONFIG_DATA | jq '.section_tags.tags[].id' | tr -d '"') | ||
TYPE_LABELS_PREFIX=$(echo $CONFIG_DATA | jq '.section_tags.prefix' | tr -d '"') | ||
|
||
COMPONENT_LABELS=$(echo $CONFIG_DATA | jq '.component_tags.tags[].id' | tr -d '"') | ||
COMPONENT_LABELS_PREFIX=$(echo $CONFIG_DATA | jq '.component_tags.prefix' | tr -d '"') | ||
|
||
LABELS_TO_ADD="" | ||
|
||
|
||
for label in $TYPE_LABELS | ||
do | ||
echo $PR_TITLE | grep -Ei "^$label*" > /dev/null | ||
|
||
if [ $? == 0 ] | ||
then | ||
LABELS_TO_ADD+="$TYPE_LABELS_PREFIX$label" | ||
fi | ||
|
||
done | ||
|
||
for label in $COMPONENT_LABELS | ||
do | ||
echo $PR_TITLE | grep -Ei "[a-z]+\(.*$label.*\):*" > /dev/null | ||
|
||
if [ $? == 0 ] | ||
then | ||
LABELS_TO_ADD+=",$COMPONENT_LABELS_PREFIX$label" | ||
fi | ||
|
||
done | ||
|
||
gh pr edit $PR_NUMBER --repo $REPO --add-label $LABELS_TO_ADD | ||
|
||
echo $LABELS_TO_ADD |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: E2E | ||
|
||
on: | ||
pull_request: | ||
types: | ||
- opened | ||
- reopened | ||
- synchronize | ||
- edited | ||
|
||
jobs: | ||
e2e-default: | ||
runs-on: ubuntu-20.04 | ||
|
||
permissions: | ||
contents: read | ||
pull-requests: write | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Test Run | ||
id: test-run | ||
uses: ./ | ||
|
||
- name: Assert placeholder | ||
uses: nick-fields/assert-action@v2 | ||
with: | ||
actual: ${{ steps.test-run.outputs.added_labels }} | ||
expected: "type/feat" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: "Add labels to PR" | ||
description: "Add labels to PR Action" | ||
|
||
inputs: | ||
github_owner: | ||
description: "Owner of the repository" | ||
default: ${{ github.repository_owner }} | ||
github_repo: | ||
description: "Repository name" | ||
default: ${{ github.event.repository.name }} | ||
github_token: | ||
description: "GitHub token" | ||
default: ${{ github.token }} | ||
github_pr_number: | ||
description: "GitHub PR number" | ||
default: ${{ github.event.pull_request.number }} | ||
github_pr_title: | ||
description: "GitHub PR title" | ||
default: ${{ github.event.pull_request.title }} | ||
|
||
outputs: | ||
added_labels: | ||
description: "Added labels to PR" | ||
value: ${{ steps.run.outputs.added_labels }} | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Run script | ||
id: run | ||
working-directory: .github/.scripts | ||
shell: bash | ||
run: echo "added_labels=$(./add_labels.sh)" >> $GITHUB_OUTPUT | ||
env: | ||
REPO: ${{ inputs.github_owner }}/${{ inputs.github_repo }} | ||
PR_NUMBER: ${{ inputs.github_pr_number }} | ||
PR_TITLE: ${{ inputs.github_pr_title }} | ||
GH_TOKEN: ${{ inputs.github_token }} | ||
|
||
branding: | ||
icon: "tag" | ||
color: "gray-dark" |