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

fix: 下書き記事が存在しない際にエラーになる現象を修正 #24

Merged
merged 1 commit into from Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/actions/move-draft-and-update-metadata/action.yaml
Expand Up @@ -5,10 +5,13 @@ runs:
steps:
- name: move draft and update metadata
run: |
draft_files=($(grep -xl 'Draft: true' $(git ls-files -mo --exclude-standard)))
draft_files=($(grep -xl 'Draft: true' $(git ls-files -mo --exclude-standard) || echo ""))
if [[ ${#draft_files[@]} -eq 0 ]]; then
exit 0
fi
for file in ${draft_files[@]}; do
entry_id=$(yq --front-matter=extract '.EditURL' "$file" | grep -oP '[^/]+\d$')
yq --front-matter=process -i 'del(.Date,.URL)' "$file"
yq --front-matter=process -i 'del(.Date,.URL)' "$file"
mv "$file" "draft_entries/$entry_id.${file##*.}"
done
shell: bash
12 changes: 7 additions & 5 deletions .github/workflows/initialize.yaml
Expand Up @@ -33,11 +33,13 @@ jobs:
- name: delete draft files
if: inputs.is_draft_included == false
run: |
target=$(git ls-files -mo --exclude-standard | xargs grep -xl 'Draft: true')
IFS=" " read -r -a draft_files <<< "$(echo "$target" | xargs)"
for file in "${draft_files[@]}"; do
rm "$file"
done
target=$(git ls-files -mo --exclude-standard | xargs grep -xl 'Draft: true' || echo "")
if [[ ! -z "$target" ]]; then
IFS=" " read -r -a draft_files <<< "$(echo "$target" | xargs)"
for file in "${draft_files[@]}"; do
rm "$file"
done
fi
- name: create pull request
uses: peter-evans/create-pull-request@v5
with:
Expand Down