Skip to content

Commit

Permalink
Draft
Browse files Browse the repository at this point in the history
  • Loading branch information
katydecorah committed Jun 19, 2024
1 parent 70dc3ba commit f96de21
Show file tree
Hide file tree
Showing 7 changed files with 364 additions and 65 deletions.
52 changes: 35 additions & 17 deletions .github/workflows/scheduled-advanced.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Seasonal scheduled post

on:
workflow_dispatch:
schedule:
- cron: "00 02 20 Mar,Jun,Sep,Dec *"

Expand All @@ -11,30 +12,47 @@ 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
local post_title=""
if [ "$season" = "Winter" ]; then
post_title="$(($YEAR - 1))/${YEAR} ${season}"
else
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
}
case $MONTH in
03)
echo "POST_TITLE=$(($YEAR - 1))/${YEAR} Winter" >> $GITHUB_ENV
echo "START_DATE=$(($YEAR - 1))-12-20" >> $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-20" >> $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-20" >> $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-20" >> $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
Expand Down
47 changes: 15 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Scheduled post action

A GitHub action that creates a scheduled post from data files generated by [read-action](https://github.com/katydecorah/read-action), [bookmark-action](https://github.com/katydecorah/bookmark-action), and [spotify-to-yaml-action](https://github.com/katydecorah/spotify-to-yaml-action).
A GitHub action that creates a scheduled post from data files generated by [read-action](https://github.com/library-pals/read-action), [bookmark-action](https://github.com/library-pals/bookmark-action), and [spotify-to-yaml-action](https://github.com/library-pals/spotify-to-yaml-action).

If you're including playlist data generated by the spotify-to-yaml-action, you'll want to make sure it's schedule to run before this action.
If you're including playlist data generated by the spotify-to-yaml-action, make sure it's schedule to run before this action.

<!-- START GENERATED DOCUMENTATION -->

Expand Down Expand Up @@ -30,7 +30,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Write scheduled post
uses: katydecorah/seasonal[email protected]
uses: library-pals/scheduled[email protected]
with:
github-username: katydecorah
github-repository: archive
Expand All @@ -55,8 +55,9 @@ jobs:
name: Seasonal scheduled post

on:
workflow_dispatch:
schedule:
- cron: "00 02 20 Mar,Jun,Sep,Dec *"
- cron: "0 1 20 Mar,Jun,Sep,Dec *"

jobs:
scheduled-post:
Expand All @@ -65,34 +66,10 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setpost title and date
run: |
MONTH=$(date +%m)
YEAR=$(date +%Y)
case $MONTH in
03)
echo "POST_TITLE=$(($YEAR - 1))/${YEAR} Winter" >> $GITHUB_ENV
echo "START_DATE=$(($YEAR - 1))-12-20" >> $GITHUB_ENV
echo "END_DATE=${YEAR}-03-20" >> $GITHUB_ENV
;;
06)
echo "POST_TITLE=${YEAR} Spring" >> $GITHUB_ENV
echo "START_DATE=${YEAR}-03-20" >> $GITHUB_ENV
echo "END_DATE=${YEAR}-06-20" >> $GITHUB_ENV
;;
09)
echo "POST_TITLE=${YEAR} Summer" >> $GITHUB_ENV
echo "START_DATE=${YEAR}-06-20" >> $GITHUB_ENV
echo "END_DATE=${YEAR}-09-20" >> $GITHUB_ENV
;;
12)
echo "POST_TITLE=${YEAR} Fall" >> $GITHUB_ENV
echo "START_DATE=${YEAR}-09-20" >> $GITHUB_ENV
echo "END_DATE=${YEAR}-12-20" >> $GITHUB_ENV
;;
esac
- name: Set post title and dates
uses: library-pals/[email protected]/workflows/set-seasonal-dates.js
- name: Write scheduled post
uses: katydecorah/[email protected]
uses: ./
with:
github-username: katydecorah
github-repository: archive
Expand Down Expand Up @@ -144,7 +121,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Write scheduled post
uses: katydecorah/seasonal[email protected]
uses: library-pals/scheduled[email protected]
with:
github-username: katydecorah
github-repository: archive
Expand Down Expand Up @@ -181,4 +158,10 @@ jobs:
- `source-playlist`: Define the file path for the playlist data generated by [spotify-to-yaml-action](https://github.com/katydecorah/spotify-to-yaml-action). If you do not have playlists, set this value to `false`. Default: `_data/playlists.yml`.

- `book-tags`: Allow specific tags to be passed through. Separate each tag with a comma.

- `start-date`: The start date for the post. The format is `YYYY-MM-DD`. This can be set as an action input or workflow input.

- `end-date`: The end date for the post. The format is `YYYY-MM-DD`. This can be set as an action input or workflow input.

- `post-title`: The title of the post. This can be set as an action input or workflow input.
<!-- END GENERATED DOCUMENTATION -->
9 changes: 9 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,12 @@ inputs:

book-tags:
description: "Allow specific tags to be passed through. Separate each tag with a comma."

start-date:
description: "The start date for the post. The format is `YYYY-MM-DD`. This can be set as an action input or workflow input."

end-date:
description: "The end date for the post. The format is `YYYY-MM-DD`. This can be set as an action input or workflow input."

post-title:
description: "The title of the post. This can be set as an action input or workflow input."
4 changes: 3 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51008,7 +51008,9 @@ function action() {
return action_awaiter(this, void 0, void 0, function* () {
try {
const payload = github.context.payload.inputs;
const { "post-title": title, "start-date": startDate, "end-date": endDate, } = payload;
const title = (payload === null || payload === void 0 ? void 0 : payload["post-title"]) || (0,core.getInput)("post-title");
const startDate = (payload === null || payload === void 0 ? void 0 : payload["start-date"]) || (0,core.getInput)("start-date");
const endDate = (payload === null || payload === void 0 ? void 0 : payload["end-date"]) || (0,core.getInput)("end-date");
validateInputs(title, startDate, endDate);
const slugifyTitle = title.toLowerCase().replace(/\s/g, "-");
const image = `${slugifyTitle}.png`;
Expand Down
Loading

0 comments on commit f96de21

Please sign in to comment.