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

This commit is contained in:
nigeljamesstevenson 2023-10-06 14:05:57 +01:00 committed by GitHub
parent 70714fc744
commit 054aeaa6e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 4 deletions

View File

@ -15,6 +15,8 @@ jobs:
run: sleep 1m
shell: bash
#... previous steps...
- name: Calculate test date
id: calculate_date
run: |
@ -23,23 +25,27 @@ jobs:
# 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 Thursday after the merge
DAYS_UNTIL_NEXT_THURSDAY=$(( (4 - MERGE_DAY_OF_WEEK + 7) % 7 + 1 ))
# Calculate days until the next Wednesday after the merge
DAYS_UNTIL_NEXT_WEDNESDAY=$(( (3 - MERGE_DAY_OF_WEEK + 7) % 7 ))
DAYS_UNTIL_NEXT_THURSDAY=$((DAYS_UNTIL_NEXT_WEDNESDAY + 1))
# 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")
THURSDAY_AFTER_MERGE_TIMESTAMP=$(date -u -d "${{ github.event.pull_request.merged_at }} + $DAYS_UNTIL_NEXT_THURSDAY days" +"%s")
WEDNESDAY_AFTER_MERGE_TIMESTAMP=$(date -u -d "${{ github.event.pull_request.merged_at }} + $DAYS_UNTIL_NEXT_WEDNESDAY days" +"%s")
if [[ "$THURSDAY_AFTER_MERGE_TIMESTAMP" -le "$CURRENT_TIMESTAMP" ]]; then
if [[ "$WEDNESDAY_AFTER_MERGE_TIMESTAMP" -le "$CURRENT_TIMESTAMP" ]]; then
TEST_DATE_MESSAGE="Can be tested from: Thursday, $THURSDAY_AFTER_MERGE"
else
TEST_DATE_MESSAGE="Can be tested from: Thursday, $NEXT_THURSDAY"
fi
echo "TEST_DATE_MESSAGE=${TEST_DATE_MESSAGE}" >> $GITHUB_ENV
#... following steps...
# Notify Slack Step
- name: Notify Slack
uses: archive/github-actions-slack@d9dae40827adf93bddf939db6552d1e392259d7d