Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

Generate story

Generate story #125

name: Generate story
on:
schedule:
- cron: "0 0 * * 3"
workflow_dispatch:
inputs:
custom_details_enabled:
description: "Whether to use the custom details below instead of the build in config"
type: boolean
default: false
genre:
description: "A main genre for the story"
type: string
options:
- science fiction
- fantasy
- crime
- horror
- action
- comedy
- drama
- folklore
- western
- young adult
theme:
description: "A theme like love, betrayal, friendship etc."
type: string
extra_details:
description: "Extra details we might want to give the story generator"
type: string
env:
OPENAI_TOKEN: ${{ secrets.OPENAI_TOKEN }}
jobs:
generate-story:
runs-on: ubuntu-latest
container:
image: ghcr.io/themkat/aitales_story_generator:7768a99948dbf51e7fd7b4ade57d25ce5dd0f382
credentials:
username: themkat
password: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Create custom config
if: ${{ inputs.custom_details_enabled }}
run: |
echo "---\ngenres:\n - ${{ inputs.genre }}\n\nthemes:\n - ${{ inputs.theme }}\n\nextra_details:\n - ${{ inputs.extra_details }}" > /generator_conf.yml
- name: generate story
working-directory: /
env:
RUST_BACKTRACE: 1
run: |
/story_generator generate
- uses: actions/checkout@v4
- name: Configure git
run: |
git config --global --add safe.directory $GITHUB_WORKSPACE
git config --global user.name 'actions (automatic)'
git config --global user.email 'action@github.com'
- name: Transform stories to jekylls markdown format
id: transform
env:
TITLE_FILE: /story_title.txt
IMAGE_URL_FILE: /story_image_url.txt
TEXT_FILE: /story_text.txt
CATEGORY_FILE: /story_genre.txt
run: |
GEN_FILENAME=$(./.github/scripts/transform_to_story.sh)
TITLE=$(cat $TITLE_FILE | tr -d '\n' | tr -d '\"')
echo "title=$TITLE" >> $GITHUB_OUTPUT
BRANCH_NAME=story-$(date '+%Y-%m-%d_%H-%M')
echo "branchname=$BRANCH_NAME" >> $GITHUB_OUTPUT
git checkout -b $BRANCH_NAME
git add _posts/$GEN_FILENAME.md
git add assets/images/$GEN_FILENAME.png
git commit -m "New story: $TITLE"
git push --set-upstream origin $BRANCH_NAME
- name: Create Pull Request
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OWNER: ${{ github.repository_owner }}
REPO: ${{ github.event.repository.name }}
run: |
gh pr create --title "New story: ${{ steps.transform.outputs.title }}" --body "New story! pls review me"