-
Notifications
You must be signed in to change notification settings - Fork 2
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 #74 from srvanrell/stop-github-workflow-no-updates
Stop GitHub workflow no updates
- Loading branch information
Showing
6 changed files
with
53 additions
and
19 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import logging | ||
import os | ||
|
||
from ranking_table_tennis.helpers.gspread import days_since_last_update | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def no_updates_stop_workflow(spreadsheet_id, max_days_since_last_update=3): | ||
"""If spreasheet_id has not been modified recently GITHUB_OUTPUT env var will stop workflow""" | ||
|
||
days_since_update = days_since_last_update(spreadsheet_id) | ||
stop_workflow = days_since_update > max_days_since_last_update | ||
logger.info( | ||
"%s days since last update. Should stop workflow? %s", days_since_update, stop_workflow | ||
) | ||
|
||
GITHUB_OUTPUT_VAR_NAME = "GITHUB_OUTPUT" | ||
var_value = f"stop_workflow={str(stop_workflow).lower()}" # true or false | ||
|
||
logger.debug("Set env var '%s': '%s'", GITHUB_OUTPUT_VAR_NAME, var_value) | ||
os.environ[GITHUB_OUTPUT_VAR_NAME] = var_value | ||
|
||
if stop_workflow: | ||
exit(0) |
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