Skip to content

Commit

Permalink
feat: add release drafter (#2)
Browse files Browse the repository at this point in the history
* Add release drafter and pr labler

* Add docstrings
  • Loading branch information
aurimasmick authored May 28, 2021
1 parent 3d86333 commit c16382a
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .github/pr-labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
enhancement: ['feature/*', 'feat/*', 'enhancement/*']
bug: ['fix/*', 'hotfix/*', 'bugfix/*', 'patch/*', 'bug/*']
chore: ['chore/*', 'docs/*']
9 changes: 9 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## Description
* List the changes you are making.
* Reference Github issue if appropriate, i.e. `closes #123`

## Breaking Changes
* Any breaking changes?

## Testing
* How was this tested?
34 changes: 34 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name-template: 'v$RESOLVED_VERSION'
tag-template: 'v$RESOLVED_VERSION'
categories:
- title: '❗ Breaking'
labels:
- 'breaking'
- title: 'Features'
labels:
- 'feature'
- 'enhancement'
- title: 'Bug Fixes'
labels:
- 'bug'
- title: 'Maintenance'
label: 'chore'
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
change-title-escapes: '\<*_&'
version-resolver:
major:
labels:
- 'breaking'
minor:
labels:
- 'enhancement'
patch:
labels:
- 'patch'
- 'bug'
- 'chore'
default: minor
template: |
# What's Changed
$CHANGES
12 changes: 12 additions & 0 deletions .github/workflows/pr-labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: PR Labeler
on:
pull_request:
types: [opened]

jobs:
pr-labeler:
runs-on: ubuntu-latest
steps:
- uses: TimonVS/pr-labeler-action@v3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
14 changes: 14 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Release Drafter

on:
push:
branches:
- main

jobs:
update_release_draft:
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8 changes: 6 additions & 2 deletions src/slacknewsbot/app.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import os
import logging
import asyncio
from aiohttp import ClientSession
import requests
import json
from functools import wraps

import requests
from aiohttp import ClientSession
from slack_sdk import WebClient


Expand All @@ -22,6 +22,7 @@


def notify_cloudwatch(function):
"""Log wrapper for CloudWatch"""
@wraps(function)
def wrapper(event, context):
logger.info(f"'{context.function_name}' - entry:'{event}'")
Expand Down Expand Up @@ -93,6 +94,7 @@ def run_graphql_query(
query,
headers,
status_code=200):
"""Get all daily Product Hunt posts with details"""
request = requests.post(PH_API_URL, data=json.dumps(query), headers=headers)
if request.status_code == status_code:
return request.json()
Expand All @@ -103,6 +105,7 @@ def run_graphql_query(
)

def create_ph_text(self):
"""Create slack text with Product Hunt top stories"""
text_list = [f"Top {STORIES_NUMBER} from Product Hunt:"]
query = {
"query": """
Expand Down Expand Up @@ -147,6 +150,7 @@ def create_ph_text(self):


def post_msg(text):
"""Send message to slack channel"""
client = WebClient(token=os.environ["SLACK_BOT_TOKEN"])
client.chat_postMessage(
channel=os.environ["SLACK_CHANNEL"],
Expand Down

0 comments on commit c16382a

Please sign in to comment.