9781835465912 2024-09-01 #228
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Add Post | |
on: | |
issues: | |
types: ['labeled','edited'] | |
jobs: | |
Checks: | |
if: contains( github.event.issue.labels.*.name, 'Publish') | |
runs-on: ubuntu-latest | |
steps: | |
- name: Echo | |
run: echo "Label is $label" | |
Build: | |
needs: Checks | |
runs-on: ubuntu-latest | |
name: Process Post | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Get current date | |
id: date | |
run: echo "::set-output name=date::$(date +'%Y-%m-%d')" | |
- name: Update title | |
env: | |
POST_TITLE: ${{ github.event.issue.title }} | |
id: title | |
run: | | |
POST_FILE=$(echo "$POST_TITLE" | tr " " "-") | |
echo "::set-output name=file::$(echo "$POST_FILE")" | |
echo "::set-output name=title::$(echo "$POST_TITLE")" | |
- name: Generate Post | |
env: | |
POST_FILE: "${{ steps.title.outputs.file }}" | |
POST_TITLE: "${{ steps.title.outputs.title }}" | |
POST_BODY: "${{ github.event.issue.body }}" | |
POST_DATE: "${{ steps.date.outputs.date }}" | |
run: | | |
cd "_posts" | |
POST_FM="---\ntitle: ${POST_TITLE}\nlayout: post\ndate: ${POST_DATE}\n\n---\n\r" | |
file="${POST_DATE}-${POST_FILE}.md" | |
echo -e "${POST_FM}${POST_BODY}" >> "$file" | |
- name: Create Pull Request | |
uses: peter-evans/create-pull-request@v7 | |
with: | |
committer: GitHub Action <[email protected]> | |
branch: "new-config-from-issue=${{ github.event.issue.number }}" | |
delete-branch: true | |
title: "publish: ${{ github.event.issue.title}}" | |
body: | | |
Automatic PR for publishing: ${{ steps.title.outputs.title }} | |
Closes #${{ github.event.issue.number }} | |
reviewers: "${{ github.repository_owner }}" | |
commit-message: "Post: ${{ github.event.issue.title }}" |