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: Create Docusaurus Page from Issue | |
on: | |
issues: | |
types: [opened, labeled] | |
jobs: | |
create-docusaurus-page: | |
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: Create and Checkout Branch | |
run: | | |
ISSUE_NUMBER=${{ github.event.issue.number }} | |
BRANCH_NAME="new-page-${ISSUE_NUMBER}" | |
git checkout -b $BRANCH_NAME | |
- name: Create Remote Branch | |
run: | | |
git commit --allow-empty -m "Initial empty commit" | |
git push -u origin $BRANCH_NAME # This will create the remote branch | |
- name: Set Git User and Email | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
- name: Create Docusaurus Markdown File | |
run: | | |
ISSUE_NUMBER=${{ github.event.issue.number }} | |
TITLE=${{ github.event.issue.body.title }} | |
DESCRIPTION=${{ github.event.issue.body.description }} | |
SIDEBAR_POSITION=${{ github.event.issue.body.sidebar_position }} | |
CONTENT=${{ github.event.issue.body.content }} | |
FILENAME="./docs/new-page-${ISSUE_NUMBER}.md" | |
echo "---" > $FILENAME | |
echo "title: $TITLE" >> $FILENAME | |
echo "description: $DESCRIPTION" >> $FILENAME | |
echo "sidebar_position: $SIDEBAR_POSITION" >> $FILENAME | |
echo "---" >> $FILENAME | |
echo "$CONTENT" >> $FILENAME | |
- name: Add, Commit and Push Changes | |
run: | | |
git add . | |
git commit -m "Create new Docusaurus page from issue $ISSUE_NUMBER" | |
git push # Now this should work without issue | |
# - name: Build Docusaurus Website | |
# run: | | |
# cd website # Navigate to your Docusaurus website directory | |
# npm install | |
# npm run build | |
# - name: Post Message to Original Issue | |
# run: | | |
# ISSUE_NUMBER=${{ github.event.issue.number }} | |
# echo "The page creation process has completed. A new branch named 'new-page-${ISSUE_NUMBER}' has been created. All tests have passed successfully." > comment.txt | |
# gh issue comment $ISSUE_NUMBER --body-file="comment.txt" | |
# env: | |
# GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create Pull Request | |
uses: peter-evans/create-pull-request@v5 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
title: "New Docusaurus Page from Issue ${{ github.event.issue.number }}" | |
branch: "new-page-${{ github.event.issue.number }}" | |
base: "Production" |