简体   繁体   English

"排除通过 github 操作发送的文件"

[英]exclude files from being sent over github actions

Im trying to find out if there is a way to exclude certain files from being sent over github actions, for example, i have a server and a client in the same repository.我试图找出是否有办法排除某些文件通过 github 操作发送,例如,我在同一个存储库中有一个服务器和一个客户端。 right now, both the server (node.js) and the client (its a react.js application) are being hosted together on azure app services.现在,服务器(node.js)和客户端(它的 react.js 应用程序)都托管在 azure 应用服务上。 once the \/<\/code> is hit, it serves up the index.html<\/code> file from the build folder.一旦\/<\/code>被击中,它就会从构建文件夹中提供index.html<\/code>文件。

however I am finding that hosting these two things together is taking its toll on the overall application, for example, it sometimes takes up to 10 seconds for the server to respond and return the index file to the client.但是我发现将这两个东西放在一起会对整个应用程序造成影响,例如,服务器有时需要长达 10 秒才能响应并将索引文件返回给客户端。 I remember in my training some of my more senior devs didnt like to host the server and client together, and im starting to see why..我记得在我的培训中,一些更高级的开发人员不喜欢同时托管服务器和客户端,我开始明白为什么..

so I likely will need to split these up to improve performance, but before i go through a daunting task of splitting the repositories up.所以我可能需要将它们拆分以提高性能,但在我完成拆分存储库的艰巨任务之前。 is there a way to specify in github actions in a workflow to ignore certain files\/folders etc..有没有办法在工作流中的 github 操作中指定忽略某些文件\/文件夹等。

the only modification i've made to this is that i added an action to zip the application for faster upload to azure to improve workload performance.我对此所做的唯一修改是我添加了一个操作来压缩应用程序,以便更快地上传到 azure 以提高工作负载性能。

here is my workflow:这是我的工作流程:

# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# More GitHub Actions for Azure: https://github.com/Azure/actions

name: Build and deploy Node.js app to Azure Web App

on:
  push:
    branches:
      - main
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2

      - name: Set up Node.js version
        uses: actions/setup-node@v1
        with:
          node-version: '14.x'

      - name: npm install, build, and test
        run: |
          npm install
          npm run build --if-present
          npm run test --if-present
      - name: Zip artifact for deployment
        run: zip release.zip ./* -r

      - name: Upload artifact for deployment job
        uses: actions/upload-artifact@v2
        with:
          name: node-app
          path: release.zip

  deploy:
    runs-on: ubuntu-latest
    needs: build
    environment:
      name: 'Production'
      url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}

    steps:
      - name: Download artifact from build job
        uses: actions/download-artifact@v2
        with:
          name: node-app
          
      - name: unzip artifact for deployment
        run: unzip release.zip
        
      - name: 'Deploy to Azure Web App'
        id: deploy-to-webapp
        uses: azure/webapps-deploy@v2
        with:
          app-name: 'Omitted'
          slot-name: 'Production'
          publish-profile: ${{SECRET}}
          package: .

You could create a shell script that excludes the files you don't want.您可以创建一个 shell 脚本来排除您不想要的文件。 In .github , create a new folder scripts ..github中,创建一个新文件夹scripts Inside the scripts folder, create a new file named exclude.sh .scripts文件夹中,创建一个名为exclude.sh的新文件。

In the exclude.sh , add the following:exclude.sh中,添加以下内容:

zip -r [file_name.zip] [files/folder to zip] -x [file path/name to exclude]

In your workflow:在您的工作流程中:

- name: unzip artifact for deployment
        run: unzip file_name.zip

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM