Created
June 22, 2020 11:59
-
-
Save lipengzhou/b92f80142afa37aea397da47366bd872 to your computer and use it in GitHub Desktop.
GitHub Actions 部署 Nuxt 应用
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: Publish And Deploy Demo | |
on: | |
push: | |
tags: | |
- 'v*' | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
# 下载源码 | |
- name: Checkout | |
uses: actions/checkout@master | |
# 打包构建 | |
- name: Build | |
uses: actions/setup-node@master | |
- run: npm install | |
- run: npm run build | |
- run: tar -zcvf release.tgz .nuxt static nuxt.config.js package.json package-lock.json | |
# 发布 Release | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@master | |
env: | |
GITHUB_TOKEN: ${{ secrets.TOKEN }} | |
with: | |
tag_name: ${{ github.ref }} | |
release_name: Release ${{ github.ref }} | |
draft: false | |
prerelease: false | |
# 上传构建结果到 Release | |
- name: Upload Release Asset | |
id: upload-release-asset | |
uses: actions/upload-release-asset@master | |
env: | |
GITHUB_TOKEN: ${{ secrets.TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./release.tgz | |
asset_name: release.tgz | |
asset_content_type: application/x-tgz | |
# 部署到服务器 | |
- name: Deploy | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USERNAME }} | |
password: ${{ secrets.PASSWORD }} | |
port: ${{ secrets.PORT }} | |
script: | | |
cd /root/realworld-nuxtjs | |
wget https://github.com/lipengzhou/realworld-nuxtjs/releases/latest/download/release.tgz -O release.tgz | |
tar zxvf release.tgz | |
npm install --production | |
pm2 reload pm2.config.js |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
点击raw不能下载,不过zip可以下载