-
Notifications
You must be signed in to change notification settings - Fork 6
80 lines (68 loc) · 2.59 KB
/
create_docusaurus_page.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
name: Create Docusaurus Page from Issue
on:
issues:
types: [labeled]
jobs:
create-branch:
runs-on: ubuntu-latest
if: github.event.label.name == 'new-page'
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: Production
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set Git User and Email
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
- name: Create and Push Branch
run: |
ISSUE_NUMBER=${{ github.event.issue.number }}
BRANCH_NAME="new-page-${ISSUE_NUMBER}"
git checkout -b $BRANCH_NAME
git push -u origin $BRANCH_NAME
commit-file:
needs: create-branch
runs-on: ubuntu-latest
if: github.event.label.name == 'new-page'
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: Production
token: ${{ secrets.GITHUB_TOKEN }}
# Here, you may consider adding a step to sanitize or parse the issue body and title.
- name: Create Docusaurus File
run: |
ISSUE_NUMBER=${{ github.event.issue.number }}
TITLE="${{ github.event.issue.title }}" # Enclosed in quotes to handle special characters
BODY="${{ github.event.issue.body }}" # Enclosed in quotes to handle special characters
FILENAME="./docs/new-page-${ISSUE_NUMBER}.md"
echo "---" > $FILENAME
echo "title: $TITLE" >> $FILENAME
echo "description: Created from Issue $ISSUE_NUMBER" >> $FILENAME
echo "sidebar_position: 1" >> $FILENAME
echo "---" >> $FILENAME
echo "$BODY" >> $FILENAME
- name: Commit and Push Changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Create new Docusaurus page from issue ${{ github.event.issue.number }}
branch: new-page-${{ github.event.issue.number }}
- name: Create Pull Request
run: |
ISSUE_NUMBER=${{ github.event.issue.number }}
BRANCH_NAME="new-page-${ISSUE_NUMBER}"
# Create PR using GitHub API
curl \
-X POST \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/pulls \
-d '{
"title": "New Docusaurus Page from Issue '${ISSUE_NUMBER}'",
"body": "This is an auto-generated PR for new Docusaurus page creation.",
"head": "'${BRANCH_NAME}'",
"base": "Production"
}'