-
Hello, I currently have a job as part of my deploy workflow which connects to my db, runs migrations and seeds the database. That takes about 2 minutes total. I was wondering if there was any way to only this job or those commands IF the I know I can write a bash script and use some sort of git command to check but I was wondering if there is an in-built way to do this? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 17 comments 6 replies
-
There is not a built-in way to do that. You need to use some commands or actions to list all the modified files and check if all of them are in the db folder.
The following is a similar case as reference:
@heathsnow, You can use “git diff” command to list all the changed files, and then check if all the changed files are under the directory “subdir/env1”. If all the changed files are under that directory, set an output with the value is true, otherwise false. Then according to the value of the output to run or not run the subsequent job which has the step echo “Updates made to env1”. A simple example: jobs: check: name: Check changed files outputs: run_job: ${{ steps.check_fil… |
Beta Was this translation helpful? Give feedback.
-
Thank you! That did the trick, however I’m stuck on another issue. I want my next job (deploy) to wait for |
Beta Was this translation helpful? Give feedback.
-
I found a “hack”. I just moved the |
Beta Was this translation helpful? Give feedback.
-
I recommend you to use needs and Job status check functions to do that.
In this way:
|
Beta Was this translation helpful? Give feedback.
-
That worked, thank you so much! Just wondering, where did you learn all of this? The docs are kind of hard to sort through, so I was wondering if there was another guide or something |
Beta Was this translation helpful? Give feedback.
-
In fact, the official documentation has provided a quite detailed guidance of these knowledge and technologies. The appropriate engineering team also will update the documentation in time for the new features, or improve some descriptions in the documentation so that readers can better understand the relevant knowledge. You can pay more attention to these documents, and learn almost all the technical guidance about GitHub Actions. |
Beta Was this translation helpful? Give feedback.
-
Thank you, I think its just a lot of information all in one place so its a little overwhelming. Also I am facing an issue. So I made a change to my
In the
so it looks like it is recognizing the change but for some reason the database job is still skipped. |
Beta Was this translation helpful? Give feedback.
-
You are referencing to an inconsistent job id in the if conditional, the expression syntax is “needs.<job id>.outputs.<output name>”.
it should be “check_database”, not “check”, you do not set job “database” needs any one job which named “check”, and there is no job “check” in your workflow.
|
Beta Was this translation helpful? Give feedback.
-
My mistake, thank you so much! |
Beta Was this translation helpful? Give feedback.
-
@nahtnam, |
Beta Was this translation helpful? Give feedback.
-
brightran:
Can you please explain this segment ??? |
Beta Was this translation helpful? Give feedback.
-
This is setting an output of a step and can be used in the subsequent steps. To view more details, you can see: |
Beta Was this translation helpful? Give feedback.
-
Can try use ‘paths’
|
Beta Was this translation helpful? Give feedback.
-
There seems to be an off-the-shelf GitHub action that solves this: paths-filter. Example from their README:
|
Beta Was this translation helpful? Give feedback.
-
You Can just use multiple .yml Files in .github/workflows |
Beta Was this translation helpful? Give feedback.
-
I'm trying to do it like this but I cannot make it work: Flow_A_:
runs-on: ubuntu-latest
if: contains(github.event.commits[0].modified[*], 'data/')
steps:
- name: Echo A
run: |
echo "This is Flow A" The return value of the As for now, using @PaulRBerg solution is the best way to do it |
Beta Was this translation helpful? Give feedback.
@nahtnam,
There is not a built-in way to do that. You need to use some commands or actions to list all the modified files and check if all of them are in the db folder.
Suppose the db folder is located at the root of the repository, you can reference to the example below: