-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
995bd11
commit 3898edd
Showing
1 changed file
with
29 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,18 +17,29 @@ jobs: | |
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Set post title and dates | ||
id: set-season | ||
run: | | ||
# Get the current month and year | ||
MONTH=$(date +%m) | ||
YEAR=$(date +%Y) | ||
# Define the seasons and corresponding emojis | ||
declare -A SEASONS=( | ||
["03"]="Winter" | ||
["06"]="Spring" | ||
["09"]="Summer" | ||
["12"]="Fall" | ||
) | ||
set_env_vars() { | ||
declare -A SEASON_EMOJI=( | ||
["Winter"]="❄️" | ||
["Spring"]="🌷" | ||
["Summer"]="☀️" | ||
["Fall"]="🍂" | ||
) | ||
# Function to set environment variables based on the season | ||
set_environment_variables_for_season() { | ||
local season=$1 | ||
local start_date=$2 | ||
local end_date=$3 | ||
|
@@ -40,23 +51,29 @@ jobs: | |
post_title="${YEAR} ${season}" | ||
fi | ||
echo "POST_TITLE=${post_title}" >> $GITHUB_ENV | ||
echo "START_DATE=${start_date}" >> $GITHUB_ENV | ||
echo "END_DATE=${end_date}" >> $GITHUB_ENV | ||
echo "POST_TITLE=${post_title}" >> $GITHUB_OUTPUT | ||
echo "START_DATE=${start_date}" >> $GITHUB_OUTPUT | ||
echo "END_DATE=${end_date}" >> $GITHUB_OUTPUT | ||
echo "SEASON_EMOJI=${SEASON_EMOJI[$season]}" >> $GITHUB_OUTPUT | ||
} | ||
# Set environment variables based on the current month | ||
case $MONTH in | ||
"03") | ||
set_env_vars ${SEASONS[$MONTH]} "$(($YEAR - 1))-12-21" "${YEAR}-03-20" | ||
set_environment_variables_for_season ${SEASONS[$MONTH]} "$(($YEAR - 1))-12-21" "${YEAR}-03-20" | ||
;; | ||
"06") | ||
set_env_vars ${SEASONS[$MONTH]} "${YEAR}-03-21" "${YEAR}-06-20" | ||
set_environment_variables_for_season ${SEASONS[$MONTH]} "${YEAR}-03-21" "${YEAR}-06-20" | ||
;; | ||
"09") | ||
set_env_vars ${SEASONS[$MONTH]} "${YEAR}-06-21" "${YEAR}-09-20" | ||
set_environment_variables_for_season ${SEASONS[$MONTH]} "${YEAR}-06-21" "${YEAR}-09-20" | ||
;; | ||
"12") | ||
set_env_vars ${SEASONS[$MONTH]} "${YEAR}-09-21" "${YEAR}-12-20" | ||
set_environment_variables_for_season ${SEASONS[$MONTH]} "${YEAR}-09-21" "${YEAR}-12-20" | ||
;; | ||
*) | ||
echo "Invalid month: $MONTH" >&2 | ||
exit 1 | ||
;; | ||
esac | ||
- name: Write metadata post | ||
|
@@ -66,15 +83,15 @@ jobs: | |
github-repository: sample-site | ||
source-bookmarks: recipes|_data/recipes.json | ||
book-tags: "recommend,skip" | ||
start-date: ${{ env.START_DATE }} | ||
end-date: ${{ env.END_DATE }} | ||
post-title: ${{ env.POST_TITLE }} | ||
start-date: ${{ steps.set-season.outputs.START_DATE }} | ||
end-date: ${{ steps.set-season.outputs.END_DATE }} | ||
post-title: ${{ steps.set-season.outputs.POST_TITLE }} | ||
env: | ||
TOKEN: ${{ secrets.TOKEN }} | ||
- name: Commit files | ||
run: | | ||
git pull | ||
git config --local user.email "[email protected]" | ||
git config --local user.name "GitHub Action" | ||
git add -A && git commit -m "${{ env.POST_TITLE }}" | ||
git add -A && git commit -m "${{steps.set-season.outputs.SEASON_EMOJI}} ${{ steps.set-season.outputs.POST_TITLE }}" | ||
git push |