Skip to content

Commit

Permalink
Create report_deploy_status.py
Browse files Browse the repository at this point in the history
  • Loading branch information
genuinemoses authored Dec 12, 2023
1 parent a8145f6 commit b7758f6
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/report_deploy_status.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import requests
import os

repo = os.getenv("GITHUB_REPOSITORY")
commit_sha = os.getenv("GITHUB_SHA")
status = "success" if os.getenv("DEPLOY_STATUS") == "success" else "failure"

url = f"https://api.github.com/repos/{repo}/statuses/{commit_sha}"

headers = {
"Authorization": f"Bearer {os.getenv('GH_TOKEN')}",
"Accept": "application/vnd.github.v3+json",
}

data = {
"state": status,
"target_url": f"https://github.com/{repo}/actions/runs/{os.getenv('GITHUB_RUN_ID')}",
"description": "Deployment Status",
"context": "continuous-integration/deploy",
}

response = requests.post(url, json=data, headers=headers)

if response.status_code != 201:
print(f"Failed to report deploy status. Status Code: {response.status_code}")
print(response.text)
exit(1)

0 comments on commit b7758f6

Please sign in to comment.