|
| 1 | +# Github Actions |
| 2 | + |
| 3 | +## workflow配置 |
| 4 | + |
| 5 | +### 关键脚本 |
| 6 | +```shell |
| 7 | +# This is a basic workflow to help you get started with Actions |
| 8 | + |
| 9 | +name: deploy # 工作流的名称 |
| 10 | + |
| 11 | +# Controls when the workflow will run |
| 12 | +on: |
| 13 | + # Triggers the workflow on push or pull request events but only for the main branch |
| 14 | + push: |
| 15 | + branches: [ deploy ] # 当push到deploy的时候触发workflow操作 |
| 16 | + # Allows you to run this workflow manually from the Actions tab |
| 17 | + workflow_dispatch: |
| 18 | + |
| 19 | +# A workflow run is made up of one or more jobs that can run sequentially or in parallel |
| 20 | +jobs: |
| 21 | + # This workflow contains a single job called "build" |
| 22 | + build: |
| 23 | + # The type of runner that the job will run on |
| 24 | + runs-on: ubuntu-latest # 在ubuntu系统上运行 |
| 25 | + # Steps represent a sequence of tasks that will be executed as part of the job |
| 26 | + steps: |
| 27 | + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it |
| 28 | + - uses: actions/checkout@v2 |
| 29 | + - name: install Node.js |
| 30 | + |
| 31 | + with: |
| 32 | + node-version: '16.X' |
| 33 | + |
| 34 | + - name: Setup pnpm |
| 35 | + # You may pin to the exact commit or the version. |
| 36 | + # uses: pnpm/action-setup@d882d12c64e032187b2edb46d3a0d003b7a43598 |
| 37 | + |
| 38 | + with: |
| 39 | + # Version of pnpm to install |
| 40 | + version: '7.X' |
| 41 | + |
| 42 | + - name: install deps |
| 43 | + run: pnpm i |
| 44 | + - name: build app |
| 45 | + run: pnpm run build |
| 46 | + |
| 47 | + - name: Deploy to the server. |
| 48 | + # 这里是通过Secure Copy Protocol (SCP) 发送到远程服务器上。可以在github编辑workflow下的yml文件,右侧会显示不同方式的用法。 |
| 49 | + uses: cross-the-world/scp-pipeline@master |
| 50 | + with: |
| 51 | + # 这里是ip地址 |
| 52 | + host: ${{ secrets.REMOTE_HOST }} |
| 53 | + # 这里是用户名(连接服务器的用户名) |
| 54 | + user: ${{ secrets.REMOTE_NAME }} |
| 55 | + # 这里是密码(连接服务器的密码) |
| 56 | + pass: ${{ secrets.REMOTE_PASS }} |
| 57 | + # 连接超时时长 不写默认是30s |
| 58 | + connect_timeout: 10s |
| 59 | + # 要把那个文件部署到服务器上 这里我要部署的是dist下的所有文件。根据实际路径切换。如果是vitePress的话:docs/.vitepress/dist/* |
| 60 | + local: 'dist/*' |
| 61 | + # 这里要部署到服务器的那个路径 example: /www/wwwroot/${xxx目录下} 以服务器的为准 |
| 62 | + remote: ${{ secrets.REMOTE_TARGET }} |
| 63 | +``` |
0 commit comments