具有超过 1 次部署的 Github Actions

问题描述 投票:0回答:1

我有一个 github 操作工作流程,我需要在其中进行 4 次部署,但所有这些都位于不同的文件夹中。所以我需要当在一个独特的存储库中进行一些更改时,它也只会在这个存储库上进行部署。

deploy:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout code
      uses: actions/checkout@v3

    - name: Authenticate to Google Cloud
      uses: google-github-actions/auth@v1
      with:
        credentials_json: ${{ secrets.GCP_SA_DEPLOY_KEY }}

    - name: Set up Google Cloud SDK
      uses: google-github-actions/setup-gcloud@v1
      with:
        project_id: ${{ secrets.GCP_PROJECT_ID }}
        install_components: 'beta'

    - name: Deploy Function 1
(deploy it just if any changes are made in ./Function1 repository)
      run: ...

    - name: Deploy Function 2
(deploy it just if any changes are made in ./Function2 repository)
      run: ...
          
    - name: Deploy Function 3
(deploy it just if any changes are made in ./Function3 repository)
      run: ...

    - name: Deploy Function 4
(deploy it just if any changes are made in ./Function4 repository)
      run: ...

我尝试使用:

if: contains(github.event.head_commit.message, './Function1')

但是什么也没发生。

希望您能理解并帮助我!谢谢!

github-actions
1个回答
0
投票

前几天,我使用了这样的多次部署

name: SSH Deploy

on:
  push:
    branches:
      - main

jobs:
  **deploy1**:
    runs-on: ubuntu-latest
    
    steps:
    - name: Checkout code
      uses: actions/checkout@v2

    - name: Setup SSH
      uses: webfactory/[email protected]
      with:
        ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
        
    - name: SSH into server 1
      run: |
        <commands>

  **deploy2**:
    needs: deploy1
    runs-on: ubuntu-latest
    
    steps:
    - name: Checkout code
      uses: actions/checkout@v2

    - name: Setup SSH
      uses: webfactory/[email protected]
      with:
        ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}

    - name: SSH into server 2
      run: |
        <commands>
© www.soinside.com 2019 - 2024. All rights reserved.