background
I recently decided to publish a study notes document on Git, which was constructed using Vuepress and then posted to Git pages. Considering that each release requires manual deployment, which is a bit tedious, I intend to use Git’s Acrions function to automate this manual process.
start
Initialize the Vupress project
As for the initialization of vuepress project, the official website has given detailed operation steps, you can go to the official website to check.
The deployment of
Step 1: Configure Pages
As for the configuration method of Pages, vuepress official website also provides a detailed description: GitPages.
Step 2: Set Deploy Key and Secrets
Git’s secret key is required when the built code needs to be pushed to the repository for future releases.
Run the following command to generate the private and public keys:
Ssh-keygen -t rsa -c 'email address'Copy the code
After generating Git, open the Git project Settings, select Deploy Keys to create the Deploy key, and fill the contents of the public key with:
Then select the Secrets option, create a private key, and fill in the private key content:
Step 3: Create an Action
Select Actions and create a New Workflow. In the Actions screen, Git will provide some templates for us to use, so we’ll use the default one
After the completion of the new, will be the default. Under our program to generate a lot/workflows/blank. Yml file, used to configure script, we will it make a little change:
The name of the ci scriptname: VUE3-STUDY DOCS CI # trigger timingon: # triggered in push phasepush: # corresponding branchbranches[main] # Trigger in PR phasepull_request: # corresponding branchbranches: [main] # Task executedjobsTask namebuildThe default is the step executed in the latest version of the Ubuntu system run-ON: Ubuntu-latest #stepsV2 # setup-node: -uses: Actions /checkout@v2 - uses: Actions /setup-node@v2 # Set the node versionwith:
node-version: '14'Compiling start: Compiling the script for Compilingrun: echo Compiling start! -run: git config --global user.email "your email address"
- run: git config --global user.name "your user name"-run: NPM install && NPM run docs: build-name: Deploy # Run: NPM install && NPM run docs: build-name: Deploy #uses: peaceiris/actions-gh-pages@v3
withYou need to set the deploy key obtained in step 2, otherwise you will be prompted that you have no permission to push the codedeploy_keyVUE3STUDY: ${{secrets.vue3study}} #external_repository: XXX/XXX # push branchpublish_branch: gh-pages # Push contentpublish_dir: docs/.vuepress/dist
Copy the code
When the configuration is complete, push the content and the action will be executed automatically:
After the command is executed, you can view the ~ page
Write in the last
This article is a simple attempt about Git actions, interested students can refer to git aciton official document to do further research ~
The documentation described in this article has been deployed
Git address, welcome ⭐️ exchange ~