The main principle is to use github action to listen for relevant events of the issue, then read the content in the issue, create a file, and submit it to git, and finally deploy it directly. This way, you can edit and display it at any time.
You can refer to the add event to myb log repository for details,
as well as the usage.
Next, let's introduce how to develop a github action:
1. Clone the template provided by the official#
The official mainly supports typescript and provides a series of toolkits. We can only develop with ts,
2. Define the parameters you want the user to input at runtime#
Define the parameters you want to define at runtime by editing the action.yml
file, such as GITHUB_TOKEN
:
name: 'add event to my blog'
description: 'add event to my blog'
author: 'fzdwx'
branding:
icon: 'archive'
color: 'white'
inputs: # Add custom parameters under this key
token:
required: true
description: 'the repo PAT or GITHUB_TOKEN'
runs:
using: 'node16'
main: 'dist/index.js'
The parameters have three attributes:
required: Whether it is required
description: Description
default: Default value
3. Implement the desired functionality#
For details, you can check my main code. In my code, I mainly did the following:
- Get the content of the current issue based on the current issue number.
- Create file content based on the predefined template.
- Submit to git.
4. Publish to the marketplace#
Check Publish this Action to the GitHub Marketplace, you may need 2fa authentication, find a github support (I use authy, in case I forget later) and you're good to go.
After successfully releasing, you can use it in other projects.