Skip to content

Commit

Permalink
fix script file
Browse files Browse the repository at this point in the history
  • Loading branch information
akotadi committed Oct 18, 2023
1 parent b07ea88 commit e8f638e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
15 changes: 2 additions & 13 deletions .github/scripts/contribution_created.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@
import re


def add_https_to_url(url):
if not url.startswith(("http://", "https://")):
url = f"https://{url}"
return url


def get_data(body):
lines = [text.strip("# ") for text in re.split('[\n\r]+', body)]

Expand Down Expand Up @@ -44,19 +38,14 @@ def main():
issue_body = event_data['issue']['body']

data = get_data(issue_body)

# remove utm-source
utm = data["url"].find("?utm_source")
if utm == -1:
utm = data["url"].find("&utm_source")
if utm != -1:
data["url"] = data["url"][:utm]

issue_title = "{} | {} | {} Location(s)".format(
data.get('company_name', '?'),
data.get('title', '?'),
len(data.get('locations', [])),
)
print('data', data)
print('issue_title', issue_title)

util.setOutput("issue_title", issue_title)

Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/contribution_created.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
issues:
types: ["labeled"]

concurrency: add_jobs

jobs:
run-python-script:
runs-on: ubuntu-latest
Expand All @@ -18,14 +20,14 @@ jobs:
with:
python-version: "3.9"

- name: execute contribution_approved.py
- name: execute contribution_created.py
id: python_script
env:
GITHUB_EVENT_PATH: ${{ github.event_path }}
run: python .github/scripts/contribution_approved.py $GITHUB_EVENT_PATH
run: python .github/scripts/contribution_created.py $GITHUB_EVENT_PATH

- name: update title
run: gh issue edit --title ${{ steps.python_script.outputs.issue_title }}
run: gh issue edit --title "${{ steps.python_script.outputs.issue_title }}"
if: success()
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit e8f638e

Please sign in to comment.