Skip to content

Correct article sorting #5

Correct article sorting

Correct article sorting #5

Workflow file for this run

name: Create issues for posts
on:
push:
paths:
- 'content/blog/**'
permissions:
issues: write
jobs:
create_post_issue:
name: Create issue if there are new posts
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# https://github.com/tj-actions/changed-files
- name: Get all changed markdown files
id: changed-markdown-files
uses: tj-actions/changed-files@v44
with:
# Avoid using single or double quotes for multiline patterns
files: |
**.md
- name: Create issue if there are new posts
if: steps.changed-markdown-files.outputs.added_files
env:
NEW_FILES: ${{ steps.changed-markdown-files.outputs.added_files }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
for post in ${NEW_FILES}; do
gh issue create \
--title "[Post] $(post)" \
--template "post-comments-template" \
--label "Post Comments"
done
close_issue_when_deleting_posts:
name: Close issue when deleting the post
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# https://github.com/tj-actions/changed-files
- name: Get all changed markdown files
id: removed-markdown-files
uses: tj-actions/changed-files@v44
with:
# Avoid using single or double quotes for multiline patterns
files: |
**.md
- name: Close issue if the post is deleted
if: steps.removed-markdown-files.outputs.deleted_files
env:
DELETED_FILES: ${{ steps.removed-markdown-files.outputs.deleted_files }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
deleted_issue_url=$(gh issue list \
--label "Post Comments" \
--json url \
--jq ".[] | any(.url | test($DELETED_FILES[]; contains)) | .url")
)
for issue_url in $(echo "$deleted_issues"); do
gh issue close $issue_url --comment "Automatically closed after post was deleted"
done