Skip to content

User Story: Be Fancy #8

User Story: Be Fancy

User Story: Be Fancy #8

name: Add New User Story
on:
issues:
types: [opened]
workflow_dispatch:
inputs:
content:
description: Description of the User Story
required: true
type: string
log-level:
description: Log Level
required: true
type: choice
options:
- debug
- info
- warning
- error
- critical
file:
description: File to read from/write to
required: false
type: string
default: "docs/user-stories/README.md"
skip-lines:
description: Number of lines to skip in the file
required: false
type: string
default: "2"
issue-number:
description: Related Issue Number
required: true
type: string
issue-url:
description: URL of the related issue
required: true
type: string
status:
description: Status of the user story
required: true
type: string
permissions: write-all
env:
MK_USERNAME: ${{ secrets.MK_USERNAME }}
MK_EMAIL: ${{ secrets.MK_EMAIL }}
PYTHONPATH: ${{ github.workspace }}/.github/scripts/
USER_STORY_FILE: ${{ github.workspace }}/docs/user-stories/README.md
USER_STORY_LOG_LEVEL: error
USER_STORY_SKIP_LINES: 2
USER_STORY_CREATE_STATUS: In-Progress
jobs:
add-user-story:
runs-on: ubuntu-latest
if: contains(github.event.issue.labels.*.name, 'user-story')
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
# Use token to allow force push
token: ${{ secrets.MK_TOKEN }}
# Make sure the actual branch is checked out when running on pull requests
ref: ${{ github.head_ref }}
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Setup User Story
run: pip install git+https://github.com/mkpro118/[email protected]
- name: Add User Story to Document
if: ${{ github.event_name == 'issues' }}
run: |
user_story --log-level $USER_STORY_LOG_LEVEL \
--file $USER_STORY_FILE \
--skip-lines $USER_STORY_SKIP_LINES \
create \
--issue-number ${{ github.event.issue.number }} \
--url ${{ github.event.issue.html_url }} \
--status $USER_STORY_CREATE_STATUS \
--content "${{ github.event.issue.body }}"
- name: Add User Story to Document (manual dispatch)
if: ${{ github.event_name == 'workflow_dispatch' }}
run: |
user_story --log-level ${{ inputs.log-level }} \
--file ${{ inputs.file }} \
--skip-lines ${{ inputs.skip-lines }} \
create \
--issue-number ${{ inputs.issue_number }} \
--url ${{ inputs.issue-url }} \
--status ${{ inputs.status }} \
--content "${{ inputs.content }}"
- name: Commit files
run: |
git config --local user.name ${MK_USERNAME}
git config --local user.email ${MK_EMAIL}
git add docs
if ! git diff-index --quiet HEAD; then
echo "Changes detected. Committing..."
git commit -m "Updated User Stories [auto-built]"
git push -f origin main
else
echo "No changes detected."
fi