diff --git a/README.md b/README.md index 4e4d399..19cafb7 100644 --- a/README.md +++ b/README.md @@ -66,30 +66,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