GitHub Actions 101: Deep Dive into Workflow Attributes
15 December, 2022
3
3
0
Contributors
Job dependencies
Recap: Each workflow must have 1 job, each job has a unique identifier, they run in parallel by default.
job1
and job2
will be run simultaneously.needs
attribute, we can ensure certain jobs to run based on another job.job1
must complete successfully before job2
can run. This means that if job1
fails, then job2
would not run. Furthermore, since job3
depends on job1
and job2
, it will not run if both jobs fail.Sequential Jobs Regardless of Success
job1
to be successful to run job2
?if
attribute. The value will be always()
which tells job2
to always run after job1
, despite the result of its run.Conditionals
if
earlier, let's take a closer look at conditionals in GitHub Actions. These can be very useful when trying to build a custom workflow with different conditions.on
attribute. This attribute must be included in any workflow because it indicates what event will trigger the workflow to run.push
, pull_request
and release
. For example:branches
attribute as conditionals, where the workflow will run if a push is on the master branch; or where the workflow will run if a pull_request is on the develop branch. Hence, the workflow will run only when these certain conditions are met.branches
, we can also use branches-ignore
to exclude certain branches from the event trigger.Note: You cannot use branches and branches-ignore under the same event of a workflow (YAML) file. Also applies to tags and tags-ignore attributes.
Environment Variables
•
•
•
Create custom variables
jobs
or steps
using the env
attribute.$VARIABLE_NAME
. For Windows, it would be $env:VARIABLE_NAME
.${{ env.VARIABLE_NAME }}
.Note: Good naming convention to keep environment variables all caps with underscores as spaces.
To be Continued
References
github
devops
automation
githubactions