简体   繁体   English

当 composer.lock 使用 SamKirkland/FTP-Deploy-Action@3.1.1 通过 github 操作更改时,如何上传供应商/文件夹

[英]How can I upload vendor/ folder when composer.lock changes through github action using SamKirkland/FTP-Deploy-Action@3.1.1

I was trying to push a laravel app to a ftp server through github action.我试图通过 github 操作将 Laravel 应用程序推送到 ftp 服务器。 Here is the snippet is from my deploy.yml file.这是来自我的 deploy.yml 文件的片段。

jobs:
  Deployment:
    name: Deploy Action
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2.1.0
        with:
          fetch-depth: 2
          
      - name: Create env file
        run: |
            touch .env
            echo APP_NAME=MyAppName >> .env
            echo APP_ENV=production >> .env
            echo APP_DEBUG=false >> .env
            echo LOG_CHANNEL=daily >> .env
            echo DB_DATABASE=${{ secrets.DEV_DB_DATABASE }} >> .env
            echo DB_USERNAME=${{ secrets.DEV_DB_USERNAME }} >> .env
            echo DB_PASSWORD=${{ secrets.DEV_DB_PASSWORD }} >> .env
            echo "!.env" > .git-ftp-include
      
      - name: Cache dependencies
        uses: actions/cache@v1
        with:
          path: ~/.composer/cache/files
          key: dependencies-composer-${{ hashFiles('composer.json') }}

      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: 7.3
          extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite
          coverage: none

      - name: Install Composer dependencies
        run: composer install --prefer-dist --no-interaction --no-suggest
        
      - name: Adding Vendor
        run: echo "!vendor/" > .git-ftp-include
      
      - name: FTP Deploy Action
        uses: SamKirkland/FTP-Deploy-Action@3.1.1
        with:
          ftp-server: ftp://${{ secrets.DEV_FTP_SERVER }}
          ftp-username: ${{ secrets.DEV_FTP_USERNAME }}
          ftp-password: ${{ secrets.DEV_FTP_PASSWORD }}

Every time when the job runs, it uploads whole vendor/ directory on FTP server.每次作业运行时,它都会在 FTP 服务器上上传整个 vendor/ 目录。 It takes a lot of time when the vendor folder uploads.供应商文件夹上传需要很多时间。 How can I just upload only changes in vendor/ directory, or if only composer.lock get modified it will upload vendor/.我如何只上传 vendor/ 目录中的更改,或者如果仅修改 composer.lock 将上传 vendor/。 Or how can I make it simple, fast and easy ?或者我怎样才能让它变得简单、快速和容易?

You can replace:您可以替换:

run: echo "!vendor/" > .git-ftp-include

for:为了:

run: echo "vendor/:composer.lock" > .git-ftp-include

However keep in mind that this:但是请记住:

will upload all files in the vendor folder, even those that are on the server already.将上传供应商文件夹中的所有文件,即使是那些已经在服务器上的文件。 And it will not delete files from that directory if local files are deleted.如果本地文件被删除,它不会从该目录中删除文件。

That could be a problem in the case in which a package removes a local file in a new version release because the file would be kept on the server, possibly causing some conflicts.如果包在新版本发布中删除本地文件,这可能是一个问题,因为该文件将保留在服务器上,可能会导致一些冲突。

See the docs here .请参阅此处的文档。

Edit: If you have already committed the composer.lock file, And you want to reupload the vendor folder for the last time, make sure to change the .lock file.编辑:如果您已经提交了 composer.lock 文件,并且您想最后一次重新上传 vendor 文件夹,请确保更改 .lock 文件。 Maybe add a new line or space to it.也许添加一个新行或空格。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 SamKirkland/FTP-Deploy-Action@3.1.1 通过 github 操作在 ftp 服务器上上传 .env 文件 - How can I upload .env file on ftp server through github action using SamKirkland/FTP-Deploy-Action@3.1.1 如何比较自 github 操作中上次操作以来的文件更改 - How to compare a file changes since last action in github actions 仅当推送的文件位于特定文件夹中时,如何运行 github 操作 - How to run github action only if the pushed files are in a specific folder 如何在 github 操作服务容器中运行命令? - How can I run a command in github action service containers? 如何在 GitHub 操作中等待容器健康? - How can I wait for the container to be healthy in GitHub action? GitHub 操作错误,因为它看不到文件夹 - GitHub Action errors because it can't see a folder 如何使用 Github 操作将多容器应用程序部署到 Azure? - How to deploy a multi-container app to Azure with a Github action? 将拉取请求合并到 master 时如何运行 Github Action? - How to run a Github Action when a pull requestion is merged to master? 当 Github 动作通过时如何合并到受保护的分支? - How to merge to a protected branch when Github Action passes? 如何使用 github 操作将代码推送到另一个用户的存储库 - how to push code to another user's repository using github action
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM