Niels Brinch
Niels Brinch

Reputation: 3642

Only release changed projects in GitHub Actions

I have 5 small Function Apps in 1 solution. I set up GitHub Actions to get them released automatically to Azure.

Every time I push new code, it runs all the actions because they are all in the same repository. But most of the time I only changed code in one of the projects.

How can I make sure that only changed Function Apps are released?

I know that I can split them up into separate repositories and solve it that way, but I am looking for a solution where I don't have to do that.

Upvotes: 2

Views: 60

Answers (1)

Robin Raju
Robin Raju

Reputation: 1325

You may create multiple workflow files for each function and specify the paths option to trigger your workflow. If at least one path matches a pattern in the paths filter, the workflow runs.

I assume your directory structure is as follows;

|_azure-functions
  |_ function1
  |_ function2

with the above sub-directories, you can define each workflow as follows.

# .github/workflows/function1-ci.yml

name: Publish Function1
on:
  push:
    branches: [ main ]
    paths:
      - "function1/**"
# .github/workflows/function2-ci.yml

name: Publish Function2
on:
  push:
    branches: [ main ]
    paths:
      - "function2/**"

Additionally, there is a paths-ignore option too available for excluding changes from locations defined. You can use a combination of this option aswell.

Upvotes: 2

Related Questions