From cb27074567883722d8552e52f9c10d0190b508ea Mon Sep 17 00:00:00 2001 From: Katy DeCorah Date: Mon, 17 Jun 2024 20:40:32 -0400 Subject: [PATCH] Update scheduled-advanced.yml --- .github/workflows/scheduled-advanced.yml | 44 +++++++++++++++--------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/.github/workflows/scheduled-advanced.yml b/.github/workflows/scheduled-advanced.yml index 849bfdf..da699f6 100644 --- a/.github/workflows/scheduled-advanced.yml +++ b/.github/workflows/scheduled-advanced.yml @@ -12,30 +12,40 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - - name: Setpost title and date + - name: Set post title and dates run: | MONTH=$(date +%m) YEAR=$(date +%Y) + + declare -A SEASONS=( + ["03"]="Winter" + ["06"]="Spring" + ["09"]="Summer" + ["12"]="Fall" + ) + + set_env_vars() { + local season=$1 + local start_date=$2 + local end_date=$3 + + echo "POST_TITLE=${YEAR} ${season}" >> $GITHUB_ENV + echo "START_DATE=${start_date}" >> $GITHUB_ENV + echo "END_DATE=${end_date}" >> $GITHUB_ENV + } + case $MONTH in - 03) - echo "POST_TITLE=$(($YEAR - 1))/${YEAR} Winter" >> $GITHUB_ENV - echo "START_DATE=$(($YEAR - 1))-12-21" >> $GITHUB_ENV - echo "END_DATE=${YEAR}-03-20" >> $GITHUB_ENV + "03") + set_env_vars ${SEASONS[$MONTH]} "$(($YEAR - 1))-12-21" "${YEAR}-03-20" ;; - 06) - echo "POST_TITLE=${YEAR} Spring" >> $GITHUB_ENV - echo "START_DATE=${YEAR}-03-21" >> $GITHUB_ENV - echo "END_DATE=${YEAR}-06-20" >> $GITHUB_ENV + "06") + set_env_vars ${SEASONS[$MONTH]} "${YEAR}-03-21" "${YEAR}-06-20" ;; - 09) - echo "POST_TITLE=${YEAR} Summer" >> $GITHUB_ENV - echo "START_DATE=${YEAR}-06-21" >> $GITHUB_ENV - echo "END_DATE=${YEAR}-09-20" >> $GITHUB_ENV + "09") + set_env_vars ${SEASONS[$MONTH]} "${YEAR}-06-21" "${YEAR}-09-20" ;; - 12) - echo "POST_TITLE=${YEAR} Fall" >> $GITHUB_ENV - echo "START_DATE=${YEAR}-09-21" >> $GITHUB_ENV - echo "END_DATE=${YEAR}-12-20" >> $GITHUB_ENV + "12") + set_env_vars ${SEASONS[$MONTH]} "${YEAR}-09-21" "${YEAR}-12-20" ;; esac - name: Write scheduled post