forked from e-mission/op-admin-dashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from MukuFlash03/tags-combo-approach
Automating image tag update for admin dashboard. Did some cleanup, but going to finalize everything in the other PR.
- Loading branch information
Showing
8 changed files
with
203 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DOCKER_IMAGE_TAG=2024-05-03--42-05 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
|
||
import json | ||
import logging | ||
import requests | ||
import sys | ||
|
||
if __name__ == '__main__': | ||
logging.basicConfig(level=logging.DEBUG) | ||
|
||
# Just checking to see if workflows are being fetched; it works!!! | ||
# download_url = "https://api.github.com/repos/MukuFlash03/e-mission-server/actions/workflows" | ||
# logging.debug("About to fetch workflows present in e-mission-server from %s" % download_url) | ||
# r = requests.get(download_url) | ||
# if r.status_code != 200: | ||
# logging.debug(f"Unable to fetch workflows, status code: {r.status_code}") | ||
# sys.exit(1) | ||
# else: | ||
# workflows_json = json.loads(r.text) | ||
# logging.debug(f"Successfully fetched workflows") | ||
# print(workflows_json) | ||
|
||
# for workflow_entry in workflows_json["workflows"]: | ||
# print("Workflow name: %s ; id: %s " % (workflow_entry["name"], workflow_entry["id"])) | ||
|
||
|
||
|
||
''' | ||
Workflow "docker image" uses image_build_push.yml | ||
From above commented out code, and checked via terminal as well, | ||
workflow id for the "docker image" can be fetched using: | ||
https://api.github.com/repos/MukuFlash03/e-mission-server/actions/workflows | ||
https://api.github.com/repos/e-mission/e-mission-server/actions/workflows | ||
For MukuFlash03: id = 75506902 | ||
For e-mission-server: id = 35580278 | ||
''' | ||
download_url = "https://api.github.com/repos/MukuFlash03/e-mission-server/actions/workflows/75506902/runs" | ||
# TODO: Comment the above line and Uncomment the below line representing the original emission repo | ||
# download_url = "https://api.github.com/repos/e-mission/e-mission-server/actions/workflows/35580278/runs" | ||
logging.debug("About to fetch workflow runs present in docker image workflow present in e-mission-server from %s" % download_url) | ||
r = requests.get(download_url) | ||
if r.status_code != 200: | ||
logging.debug(f"Unable to fetch workflow runs, status code: {r.status_code}") | ||
sys.exit(1) | ||
else: | ||
workflow_runs_json = json.loads(r.text) | ||
logging.debug(f"Successfully fetched workflow runs") | ||
# print(workflow_runs_json) | ||
|
||
workflow_runs = workflow_runs_json["workflow_runs"] | ||
if workflow_runs: | ||
# TODO: Change the head_branch name which identifies only e-mission-server runs triggered by this branch | ||
successful_runs = [run for run in workflow_runs \ | ||
if run["status"] == "completed" and \ | ||
run["conclusion"] == "success" and \ | ||
run["head_branch"] == "tags-combo-approach" | ||
] | ||
# print(successful_runs) | ||
if successful_runs: | ||
sorted_runs = successful_runs.sort(reverse=True, key=lambda x: x["updated_at"]) | ||
sorted_runs = sorted(successful_runs, reverse=True, key=lambda x: x["updated_at"]) | ||
# print(sorted_runs) | ||
latest_run_id = sorted_runs[0]["id"] | ||
# print(latest_run_id) | ||
print(f"::set-output name=run_id::{latest_run_id}") | ||
# else: | ||
# print("No successful runs") | ||
# else: | ||
# print("No workflow runs found") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters