Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

記事の連番の採番を既存のポスト数から自動で行う #210

Merged
merged 2 commits into from
Sep 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions .github/workflows/create_post.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ name: "Create post"
on:
workflow_dispatch:
inputs:
post_number:
description: '3桁の連番。例:001'
required: true
type: string
post_date:
description: '8桁の投稿日。例:20220404'
required: true
Expand All @@ -28,25 +24,30 @@ jobs:
git config --local user.name github-actions[bot]
git config --local user.email 41898282+github-actions[bot]@users.noreply.github.com

- name: Set the post number
run: |
POST_NUMBER=$(($(ls Content/posts | wc -l | awk '{print $1}') - 1))
echo "post_number=$POST_NUMBER" >> $GITHUB_ENV

- name: Create and switch work branch
id: create_work_branch
run: |
WORK_BRANCH_NAME="feature/${{ github.event.inputs.post_number }}_${{ github.event.inputs.post_date }}"
WORK_BRANCH_NAME="feature/${{ env.post_number }}_${{ github.event.inputs.post_date }}"
git switch -c "$WORK_BRANCH_NAME"
echo "work_branch_name=$WORK_BRANCH_NAME" >> $GITHUB_OUTPUT

- name: Create post
id: create_post
run: |
POST_FILENAME="${{ github.event.inputs.post_number }}-${{ github.event.inputs.post_date }}.md"
POST_FILENAME="${{ env.post_number }}-${{ github.event.inputs.post_date }}.md"
POST_FILE="./Content/posts/$POST_FILENAME"
POST_DATE_BEFORE=${{ github.event.inputs.post_date }}
POST_YEAR=${POST_DATE_BEFORE:0:4}
POST_MONTH=${POST_DATE_BEFORE:4:2}
POST_DAY=${POST_DATE_BEFORE:6:2}
POST_DATE=$POST_YEAR-$POST_MONTH-$POST_DAY
touch $POST_FILE
echo -e "---\ndate: $POST_DATE 09:00\ndescription: TBD\n---\n# ${{ github.event.inputs.post_number }} $POST_DATE\n\n## TBD\n\n{ニュースなどを書く}\n\n## Apple のソフトウェアリリース情報\n\nApple が提供している OS や IDE のリリース情報です。\n\n### 正式版\n\n- [TBD](TBD)\n\n### 開発者向けベータ\n\n- [TBD](TBD)\n\n## OSS のリリース情報\n\niOS アプリ開発でよく使われている OSS のリリース情報です。\n\n### Apple\n\n#### TBD\n\n[TBD](TBD)\n\nTBD\n\n### サードパーティ\n\n#### TBD\n\n[TBD](TBD)\n\nTBD" > $POST_FILE
echo -e "---\ndate: $POST_DATE 09:00\ndescription: TBD\n---\n# ${{ env.post_number }} $POST_DATE\n\n## TBD\n\n{ニュースなどを書く}\n\n## Apple のソフトウェアリリース情報\n\nApple が提供している OS や IDE のリリース情報です。\n\n### 正式版\n\n- [TBD](TBD)\n\n### 開発者向けベータ\n\n- [TBD](TBD)\n\n## OSS のリリース情報\n\niOS アプリ開発でよく使われている OSS のリリース情報です。\n\n### Apple\n\n#### TBD\n\n[TBD](TBD)\n\nTBD\n\n### サードパーティ\n\n#### TBD\n\n[TBD](TBD)\n\nTBD" > $POST_FILE
git add $POST_FILE
git commit -m "Create $POST_FILENAME"
git push origin ${{ steps.create_work_branch.outputs.work_branch_name }}
Expand Down