Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test PR #3

Open
wants to merge 32 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
f7225a1
Create check_release_notes.yml
danudey Sep 1, 2023
3c6189c
Update check_release_notes.yml
danudey Sep 1, 2023
4a2d757
Update check_release_notes.yml
danudey Sep 1, 2023
56deb73
Update check_release_notes.yml
danudey Sep 1, 2023
3dbf369
Update check_release_notes.yml
danudey Sep 1, 2023
4c52a75
Add more test workflow stuff
danudey Jul 4, 2024
7d35078
Add more test workflow stuff
danudey Jul 4, 2024
56c7cf1
Add more test workflow stuff
danudey Jul 4, 2024
c2785e6
Add more test workflow stuff
danudey Jul 4, 2024
a14569d
Add more test workflow stuff
danudey Jul 4, 2024
3ad3754
Add more test workflow stuff
danudey Jul 4, 2024
bf36de6
Add more test workflow stuff
danudey Jul 4, 2024
4ae441c
Add more test workflow stuff
danudey Jul 4, 2024
3b193bf
Add more test workflow stuff
danudey Jul 4, 2024
d8e22e1
Add more test workflow stuff
danudey Jul 4, 2024
d45b693
Add more test workflow stuff
danudey Jul 4, 2024
d189fd5
Add more test workflow stuff
danudey Jul 4, 2024
4fd4fbb
Add more test workflow stuff
danudey Jul 4, 2024
34e8184
Add more test workflow stuff
danudey Jul 4, 2024
50826ae
Add more test workflow stuff
danudey Jul 4, 2024
7d6194e
Add more test workflow stuff
danudey Jul 4, 2024
19fa9b3
Add more test workflow stuff
danudey Jul 4, 2024
4a8df07
Add more test workflow stuff
danudey Jul 4, 2024
03abdbd
Add more test workflow stuff
danudey Jul 4, 2024
ee70448
Add more test workflow stuff
danudey Jul 4, 2024
df317d9
Add new test action
danudey Jul 4, 2024
b6fde07
Add new test action
danudey Jul 4, 2024
09aca5c
Don't use a specified version
danudey Jul 4, 2024
0427e4e
Use master
danudey Jul 4, 2024
361e4b5
Test a new thing
danudey Aug 21, 2024
97f701a
Test a new thing
danudey Aug 21, 2024
c71e196
Remove garbage
danudey Aug 21, 2024
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
38 changes: 38 additions & 0 deletions .github/workflows/check_release_notes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# This workflow will triage pull requests and apply a label based on the
# paths that are modified in the pull request.
#
# To use this workflow, you will need to set up a .github/labeler.yml
# file with configuration. For more information, see:
# https://github.com/actions/labeler

name: Labeler
on:
pull_request:
types: [labeled, unlabeled, edited, synchronize]

jobs:
label:

runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write

steps:
- name: Test New Action
uses: danudey/check-release-notes@main
# - name: Checkout
# uses: actions/checkout@v4
# with:
# sparse-checkout: .
# - name: Setup Python
# uses: actions/setup-python@v5
# with:
# python-version: '3.12'
# cache: 'pip' # caching pip dependencies
# - name: Install GitHub Python module
# id: gh-py-mod
# run: python3 -m pip install -U -r requirements.txt
# - name: Check Release Notes
# id: release-notes
# run: ./check_release_notes.py
58 changes: 58 additions & 0 deletions check_release_notes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/env python3

import os
import re
import sys
import json

import github

def get_env(env_name):
value = os.getenv(env_name)
# print(f"ENV {env_name} = {value}", file=sys.stdout)
return value

def fail(message):
with open(GITHUB_RESULT_PATH, "a+") as output_file:
output_file.write(message + "\n")
# print(f'FAIL: {message}', file=sys.stderr)
print(f'::error::{message}')

def info(message):
with open(GITHUB_RESULT_PATH, "a+") as output_file:
output_file.write(message + "\n")
# print(f'INFO: {message}', file=sys.stderr)
print(f'::notice::{message}')


GITHUB_EVENT_PATH = get_env("GITHUB_EVENT_PATH")
GITHUB_RESULT_PATH = get_env("GITHUB_STEP_SUMMARY")

github_data = json.load(open(GITHUB_EVENT_PATH))

gh = github.Github()

repo_name = get_env("GITHUB_REPOSITORY")
pr_number = github_data['number']

repo = gh.get_repo(repo_name)
pr = repo.get_pull(pr_number)

release_note_label = repo.get_label("release-note-required")

if release_note_label in pr.labels:
if result := re.search("(?<=```release-note\n).*?(?=\n```)", pr.body, re.DOTALL):
release_note = result.group().strip()
if not release_note:
fail('Release note is empty')
sys.exit(-1)
if release_note.lower() == "tbd":
fail('Release note contains "TBD"')
sys.exit(-1)
else:
fail('No release notes found in PR body')
sys.exit(-1)
else:
info('No release note required')

sys.exit(0)
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PyGithub