About GitHub Actions


It is a workflow automation services offered by GitHub Company. This help in all kinds of repository related process and actions 

Repository you can consider as buckets where you can store code for applications 




Github Runners: About GitHub-hosted runners - GitHub Docs



npm install 

or 

np ci which installs what is locked inside the file which will make sure that it does not install some breaking versions.







If you want this to run in sequence, we need to use the "needs" keyword
 you can also mentioned 

needs [ job1 , job2 ] - multiple jobs to finish



you can add more event triggers 







or you can write it like a list 



say if you want to add a workflow_dispatch










Link : Workflow Event Filters Events that trigger workflows - GitHub Docs







Link GitHub Context Value: Accessing contextual information about workflow runs - GitHub Docs









The hash value will change 
We give this cache a key . The idea is that we will use this cache to retrieve this cache in the future and recreating that folder on the runner machine . The key also indicated weather the hash should be discarded because it has to be recreated because of some dependency change.

It create a unique hashvalue based on the file path that you gave to it.. The hash value will change wherever we the file that pass to it changes. so when the content of the file change.




https://github.com/actions/cache


Artifacts :   are the output files that your jobs produce 
Caches : Caches are for Dependencies



You can also define the environment variables in the job level.








Environment Specific Jobs


Link Context Object: 




Step Context:





The default function of a workflow is if a step fails the rest of the steps in the workflow will fail.
if you want the next step if the workflow runs if the previous job fails .
In order to change the default behavior, you must
combine it with failure () function with steps. <job_id>. outcome == "failure"





If any previous job failed, this job would run. with failure function.
You must add the needs key here so that it checks if the previous job has failed or not.





continue-on-error ensures that the workflow continues in spite of the job fails.


Matrix Value:



This matrix will run on all combinations on 


You can use "include" reserved key which will help you to set to one specific combination.


You can use the "exclude" key word so that this one will be excluded from the general combination.



Reusable workflow:


To call a reusable workflow the on key word becomes important


Calling the reusable workflow.



This can also be a path defines in another repository. But in this case, we are referring to the same path

Calling reusable workflow from a different repo

name: Call Deploy Workflow

on:
  push:
    branches: [main]

jobs:
  call-deploy:
    uses: org/shared-workflows/.github/workflows/deploy.yml@main
    with:
      environment: production

Running jobs in Container



Services:

In GitHub Actions, services are used to define Docker containers that your job can interact with during a workflow run. This is particularly useful for setting up databases, message queues, or other dependent services your tests need.

example:

    services:
      postgres:
        image: postgres:14
        env:
          POSTGRES_USER: user
          POSTGRES_PASSWORD: password
          POSTGRES_DB: mydb
        ports:
          - 5432:5432
        options: >-
          --health-cmd="pg_isready"
          --health-interval=10s
          --health-timeout=5s
          --health-retries=5



services:




Comments

Popular posts from this blog