Create Other Post #4
This file contains hidden or 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: Create New Post PR | |
description: Creates a new PR. The PR's body will be used to populate a new post in my blog. | |
on: | |
workflow_dispatch: | |
inputs: | |
name: | |
type: string | |
required: true | |
description: Name of the branch to create. It will be lowercased and all spaces will be replaced by dashes. | |
jobs: | |
create-branch-and-pr: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Make draft item and get branch name | |
id: get_name | |
run: | | |
branch_name=$(echo "${{ github.event.inputs.name }}" | tr '[:upper:]' '[:lower:]' | tr ' ' '-') | |
# Create an item in drafts directory | |
touch drafts/${branch_name} | |
git add drafts | |
git commit -m "create PR from branch ${branch_name}" | |
echo "branch_name=$branch_name" >> $GITHUB_OUTPUT | |
- name: Create Pull Request | |
id: create_pr | |
uses: peter-evans/create-pull-request@v7 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
branch: ${{ steps.get_name.outputs.branch_name }} | |
base: main | |
title: posts/${{ steps.get_name.outputs.branch_name }} | |
body-path: '${{ github.workspace }}/.github/PULL_REQUEST_TEMPLATE/post.md' | |
labels: 'post' |