Update test-assistant-api-with-date.yml

This commit is contained in:
nigeljamesstevenson 2023-10-06 13:21:45 +01:00 committed by GitHub
parent 2907e31c46
commit 8fa7906385
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 5 deletions

View File

@ -19,23 +19,25 @@ jobs:
id: calculate_date
run: |
#!/bin/bash
MERGED_TIMESTAMP=$(date -u -d "${{ github.event.pull_request.merged_at }}" +"%s")
# Get the day of the week of the merged PR (0 for Sunday, 1 for Monday, etc.)
MERGE_DAY_OF_WEEK=$(date -u -d "${{ github.event.pull_request.merged_at }}" +"%u")
# Calculate days until the next Wednesday after the merge
DAYS_UNTIL_NEXT_WEDNESDAY=$(( (3 - MERGE_DAY_OF_WEEK + 7) % 7 + 1 ))
DAYS_UNTIL_NEXT_THURSDAY=$((DAYS_UNTIL_NEXT_WEDNESDAY + 1))
# Calculate the next Wednesday timestamp after the merge
WEDNESDAY_AFTER_MERGE_TIMESTAMP=$(date -u -d "${{ github.event.pull_request.merged_at }} + $DAYS_UNTIL_NEXT_WEDNESDAY days" +"%s")
# Calculate the date for the next Thursday after the merge
THURSDAY_AFTER_MERGE=$(date -u -d "${{ github.event.pull_request.merged_at }} + $DAYS_UNTIL_NEXT_THURSDAY days" +"%Y-%m-%d")
NEXT_THURSDAY=$(date -u -d "${{ github.event.pull_request.merged_at }} + $(($DAYS_UNTIL_NEXT_THURSDAY + 7)) days" +"%Y-%m-%d")
CURRENT_TIMESTAMP=$(date -u +"%s")
WEDNESDAY_AFTER_MERGE_TIMESTAMP=$(date -u -d "${{ github.event.pull_request.merged_at }} + $DAYS_UNTIL_NEXT_WEDNESDAY days" +"%s")
if [[ "$WEDNESDAY_AFTER_MERGE_TIMESTAMP" -le "$CURRENT_TIMESTAMP" ]]; then
TEST_DATE_MESSAGE="Can be tested this Thursday"
TEST_DATE_MESSAGE="Can be tested from: Thursday, $THURSDAY_AFTER_MERGE"
else
TEST_DATE_MESSAGE="Can be tested next Thursday"
TEST_DATE_MESSAGE="Can be tested from: Thursday, $NEXT_THURSDAY"
fi
echo "TEST_DATE_MESSAGE=${TEST_DATE_MESSAGE}" >> $GITHUB_ENV