Last active
June 2, 2020 02:08
-
-
Save nashmaniac/3772cebeec07b3b8ee3f4b82071d17bd to your computer and use it in GitHub Desktop.
Job Definition
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# there might be multiple jobs definition under jobs. | |
# this is the job annotation. It can contain multiple job | |
# in each job definition runs-on and steps are required. | |
jobs: | |
# name of the job to be shown in GitHub | |
first-job: | |
# os in which the job will run | |
# Possible values are ubuntu-latest, windows-latest, ubuntu-16.04 | |
# there might be many version. | |
runs-on: ubuntu-latest # required | |
# job specific env variables | |
# this env variables won't be available to second-job | |
env: | |
ENV_VAR: hello-world | |
SECOND_VAR: hello-world | |
# I will explain the steps separately. Generally steps are list of objects. | |
steps: # required | |
- | |
second-job: | |
runs-on: windows-latest | |
steps: | |
- | |
# One more interesting thing you can do is to run a job in different os | |
# For this, you need to strategy under each job config | |
jobs: | |
first-job: | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
# This will allow the job to run in 3 different os | |
runs-on: ${{ matrix.os }} | |
steps: | |
- | |
# Apart from this you can also run all the steps in a docker container | |
jobs: | |
first-job: | |
runs-on: ubuntu-latest | |
container: | |
# this will run all the steps in this job inside a python:3 docker container | |
image: "python:3" | |
steps: | |
- | |
# By default all the jobs that are defined under jobs keywords | |
# Sometime we need to start a job after a job is finished. | |
# for this we need the needs keyword | |
jobs: | |
# as first-job and fourth-job don't have any needs keywords | |
# they will start together | |
first-job: | |
second-job: | |
# only run when first-job is successful | |
needs: [first-job] | |
third-job: | |
# only run when first-job and second-job is successful | |
needs: [first-job, second-job] | |
fourth-job: | |
# also sometimes you need docker container to be started as sidecar for a job to run | |
jobs: | |
first-job: | |
services: | |
postgres: | |
image: postgres # docker image name | |
ports: | |
- "5432:5432" #port exposed | |
redis: | |
image: redis |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment