I have a github actions workflow that in there I need to do 4 deploys, but all of then are in different folders. So I need that when some changes are made in an unique repository, it just makes deploy on this depository also.
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: ...
I tried using:
if: contains(github.event.head_commit.message, './Function1')
but nothing happens.
Hope you could understand and help me! Thanks!
2
Answers
some days ago, I used multiple deploy like this. In my case I also make dependent on each other..
You could use reusable workflow files. The following should give you an idea (of course you have to adapt it to your actual build steps).
First create a workflow file, e.g.
.github/workflows/wf-deploy-function.yml
:Now create a yml file for each of your Function apps.
E.g.
.github/workflows/DeployFunction1.yml
E.g.
.github/workflows/DeployFunction2.yml
For each of these files you can define the paths on which a change will trigger the workflow.