File tree Expand file tree Collapse file tree 2 files changed +45
-3
lines changed
Expand file tree Collapse file tree 2 files changed +45
-3
lines changed Original file line number Diff line number Diff line change 1+ name : Create New Post PR
2+ description : Creates a new PR. The PR's body will be used to populate a new post in my blog.
3+
4+ on :
5+ workflow_dispatch :
6+ inputs :
7+ name :
8+ type : string
9+ required : true
10+ description : Name of the branch to create. It will be lowercased and all spaces will be replaced by dashes.
11+
12+ jobs :
13+ create-branch-and-pr :
14+ runs-on : ubuntu-latest
15+
16+ steps :
17+ - name : Checkout repository
18+ uses : actions/checkout@v4
19+
20+ - name : Create new branch
21+ id : create_branch
22+ run : |
23+ git config --global user.name 'github-actions[bot]'
24+ git config --global user.email 'github-actions[bot]@users.noreply.github.com'
25+ branch_name=$(echo "${{ github.event.inputs.name }}" | tr '[:upper:]' '[:lower:]' | tr ' ' '-')
26+ echo "Branch name: ${branch_name}"
27+ git checkout -b "$branch_name"
28+ git push origin "$branch_name"
29+ echo "branch_name=$branch_name" >> $GITHUB_OUTPUT
30+
31+ - name : Create Pull Request
32+ id : create_pr
33+ uses : peter-evans/create-pull-request@v7
34+ with :
35+ token : ${{ secrets.GITHUB_TOKEN }}
36+ branch : ${{ steps.create_branch.outputs.branch_name }}
37+ base : main
38+ title : posts/${{ steps.create_branch.outputs.branch_name }}
39+ body-path : ' ${{ github.workspace }}/.github/PULL_REQUEST_TEMPLATE/post.md'
40+ labels : ' post'
Original file line number Diff line number Diff line change 1- name : Create Post from PR
1+ name : Generate post from PR
2+ description : When a PR that has label `post` is merged, this action will generate a new post from the PR's body.
23
34on :
45 pull_request :
56 types : [labeled, closed]
67
78jobs :
8- create_post :
9+ generate_post :
910 if : ${{ (github.event.pull_request.merged == true && github.event.label.name == 'post') }}
1011 runs-on : ubuntu-latest
1112
1617 - name : Create post file
1718 id : create_post
1819 run : |
19- PR_TITLE=$(echo "${{ github.event.pull_request.title }}" | tr '[:upper:]' '[:lower:]' | tr ' ' '-')
20+ PR_TITLE=${{ github.event.pull_request.title }}
21+ PR_TITLE=${PR_TITLE#post/}
2022 DATE=$(date +'%Y-%m-%d')
2123 PR_TITLE="${DATE}-${PR_TITLE}"
2224 PR_BODY=${{ github.event.pull_request.body }}
You can’t perform that action at this time.
0 commit comments