Skip to content

Commit

Permalink
Merge pull request #2 from rohammosalli/brnach-test
Browse files Browse the repository at this point in the history
add branch sensitive
  • Loading branch information
rohammosalli committed May 17, 2023
2 parents 9fa57ca + 72118fb commit ac01ce1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ inputs:
required: true
runs:
using: "docker"
image: "docker://rohammosalli/slack-action:v2.0.0"
image: "docker://rohammosalli/slack-action:v2.1.0"
13 changes: 9 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ def get_workflow_run_jobs(run_id):
return response.json()['jobs']


def get_previous_workflow_run(run_id):
url = f"https://github.com/gitapi/repos/{REPO_OWNER}/{REPO_NAME}/actions/runs?per_page=2"
response = requests.get(url, headers=get_headers())
def get_previous_workflow_run(repo_owner, repo_name, run_id, branch, headers):
url = f"https://github.com/gitapi/repos/{repo_owner}/{repo_name}/actions/runs?per_page=2"
if branch:
url += f"&branch={branch}"
response = requests.get(url, headers=headers)
response.raise_for_status()
runs = response.json()['workflow_runs']
for run in runs:
Expand Down Expand Up @@ -84,7 +86,10 @@ def send_slack_notification(message):
commit_url = f"https://github.com/{REPO_OWNER}/{REPO_NAME}/commit/{commit_sha}"
workflow_url = current_workflow_run['html_url']

previous_workflow_run = get_previous_workflow_run(RUN_ID)

branch = current_workflow_run['head_branch']
previous_workflow_run = get_previous_workflow_run(
REPO_OWNER, REPO_NAME, RUN_ID, branch, get_headers())

workflow_id = current_workflow_run['workflow_id']
current_run_number = current_workflow_run['run_number']
Expand Down
8 changes: 0 additions & 8 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
certifi==2023.5.7
cffi==1.15.1
charset-normalizer==3.1.0
cryptography==40.0.2
Deprecated==1.2.13
idna==3.4
pycparser==2.21
PyGithub==1.58.2
PyJWT==2.7.0
PyNaCl==1.5.0
requests==2.30.0
slack-sdk==3.21.3
urllib3==2.0.2
wrapt==1.15.0

0 comments on commit ac01ce1

Please sign in to comment.