如何运行github action在数字海洋上部署和构建Node应用程序?

2o7dmzc5  于 2023-02-28  发布在  Git
关注(0)|答案(1)|浏览(168)

我正在尝试用以下步骤编写github操作工作流:
1.通过ssh连接到数字海洋
1.导航到/saver文件夹
1.从main分支获取更新
1.安装依赖项并生成项目
我当前的代码如下所示

name: Deploy app

on:
  push:
    branches: [ main ]

jobs:
  build:
    runs-on: ubuntu-20.04

    steps:
      - name: Deploy to Digital Ocean
        uses: appleboy/ssh-action@master
        with: 
          host: ${{secrets.SSH_HOST}}
          key: ${{secrets.SSH_KEY}}
          username: ${{secrets.SSH_USERNAME}}
          passphrase: ${{secrets.SSH_PASSPHRASE}}
          script: |
            cd saver 
            mkdir test #just to check if it connects and creates folder
        
      - name: Checkout
        uses: actions/checkout@v3
        with:
          ref: main

      - name: Pull changes
        run: git pull
         
      - name: Install client dependencies
        run: npm run client:prodinstall
                
      - name: Build client
        run: npm run client:build

      - name: Install server dependencies
        run: npm run server:prodinstall

      - name: Install server dependencies
        run: npm run server:build

正如我在logs中看到的,成功登录到数字海洋。在服务器上,我看到文件夹test。但是git pull不工作。我看到

Run git pull
  
Already up to date.

但是如果我自己导航到DO server并运行git pull,我会得到新的更改。
怎么啦?

agxfikkp

agxfikkp1#

如何通过ssh运行它?
您需要在appleboy/ssh-action@master运行的命令中包含您的git pull
这意味着该操作的script部分应该包括cd /path/to/repositorygit pull

相关问题