Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/update_changelog/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ runs:
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git config --local github.token ${{ env.UPDATE_REPO_TOKEN }}
git config --local github.token ${{ env.YDBOT_TOKEN }}
python ${{ github.action_path }}/update_changelog.py pr_data.txt "${{ inputs.changelog_path }}" "${{ inputs.base_branch }}" "${{ inputs.suffix }}"
7 changes: 4 additions & 3 deletions .github/actions/update_changelog/update_changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
CATEGORY_PREFIX = "### "
ITEM_PREFIX = "* "

YDBOT_TOKEN = os.getenv("YDBOT_TOKEN")

@functools.cache
def get_github_api_url():
return os.getenv('GITHUB_REPOSITORY')
Expand Down Expand Up @@ -150,7 +152,7 @@ def fetch_pr_details(pr_id):
url = f"https://api.github.com/repos/{get_github_api_url()}/pulls/{pr_id}"
headers = {
"Accept": "application/vnd.github.v3+json",
"Authorization": f"token {GITHUB_TOKEN}"
"Authorization": f"token {YDBOT_TOKEN}"
}
response = requests.get(url, headers=headers)
response.raise_for_status()
Expand All @@ -160,7 +162,7 @@ def fetch_user_details(username):
url = f"https://api.github.com/users/{username}"
headers = {
"Accept": "application/vnd.github.v3+json",
"Authorization": f"token {GITHUB_TOKEN}"
"Authorization": f"token {YDBOT_TOKEN}"
}
response = requests.get(url, headers=headers)
response.raise_for_status()
Expand All @@ -176,7 +178,6 @@ def fetch_user_details(username):
base_branch = sys.argv[3]
suffix = sys.argv[4]

GITHUB_TOKEN = os.getenv("UPDATE_REPO_TOKEN")

try:
with open(pr_data_file, 'r') as file:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from github.PullRequest import PullRequest

def post(is_valid, error_description):
gh = Github(auth=GithubAuth.Token(os.environ["GITHUB_TOKEN"]))
gh = Github(auth=GithubAuth.Token(os.environ["YDBOT_TOKEN"]))

with open(os.environ["GITHUB_EVENT_PATH"]) as fp:
event = json.load(fp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
from typing import Tuple

issue_patterns = [
r"https://github.com/ydb-platform/ydb/issues/\d+",
r"https://st.yandex-team.ru/[a-zA-Z]+-\d+",
r"#+d+",
r"[a-zA-Z]+-\d+"
r"https://github.com/ydb-platform/[a-z\-]+/issues/\d+",
r"https://st.yandex-team.ru/[a-zA-Z]+-\d+"
]

pull_request_template = """
Expand All @@ -27,15 +25,15 @@
* Not for changelog (changelog entry is not required)
"""

def validate_pr_description(description, is_not_for_cl_valid=True) -> bool:
def validate_pr_description(description:str, is_not_for_cl_valid:bool=True) -> bool:
try:
result, _ = check_pr_description(description, is_not_for_cl_valid)
return result
except Exception as e:
print(f"::error::Error during validation: {e}")
return False

def check_pr_description(description, is_not_for_cl_valid=True) -> Tuple[bool, str]:
def check_pr_description(description:str, is_not_for_cl_valid:bool=True) -> Tuple[bool, str]:
if not description.strip():
txt = "PR description is empty. Please fill it out."
print(f"::warning::{txt}")
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/update_changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ on:
required: true
default: "changelog-for-"

env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
gather-prs:
runs-on: ubuntu-latest
Expand All @@ -35,6 +32,8 @@ jobs:

- name: Get merged PRs
id: pr-list
env:
GH_TOKEN: ${{ secrets.YDBOT_TOKEN }}
run: |
TYPE="${{ github.event.inputs.type }}"
START="${{ github.event.inputs.start }}"
Expand Down Expand Up @@ -86,7 +85,7 @@ jobs:
- name: Update Changelog
uses: ./.github/actions/update_changelog
env:
UPDATE_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
YDBOT_TOKEN: ${{ secrets.YDBOT_TOKEN }}
with:
pr_data: "${{ needs.gather-prs.outputs.prs }}"
changelog_path: "${{ github.event.inputs.changelog_path }}"
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/weekly_update_changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ on:
- main
- stable-*
workflow_dispatch:
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
gather-prs:
Expand All @@ -27,6 +25,8 @@ jobs:

- name: Get merged PRs
id: pr-list
env:
GH_TOKEN: ${{ secrets.YDBOT_TOKEN }}
run: |
echo "::notice:: branch = ${GITHUB_REF_NAME}, date = $LAST_WEEK_DATE"
PRS=$(gh pr list --state merged --json number,title,baseRefName,mergedAt --jq ".[] | select(.baseRefName == \"${GITHUB_REF_NAME}\" and .mergedAt >= \"$LAST_WEEK_DATE\") | {id: .number}" | jq -c -s ".")
Expand Down Expand Up @@ -63,7 +63,7 @@ jobs:
- name: Update Changelog
uses: ./.github/actions/update_changelog
env:
UPDATE_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
YDBOT_TOKEN: ${{ secrets.YDBOT_TOKEN }}
with:
pr_data: "${{ needs.gather-prs.outputs.prs }}"
changelog_path: "./CHANGELOG.md" # RODO: Use the correct path to your CHANGELOG.md file
Expand Down