Git Product home page Git Product logo

gitactions's Introduction

Rules

Things to remember :

Refer /.github/workflows/ for code

  1. Format
  2. Events
  3. Jobs
  4. Steps vs Actions
  5. Steps-
    1. Change Shell
    2. Run - python , shell
    3. Run Git string operations
    4. if Condition
    5. Use Variables
    6. Use sh file
    7. Error handling
  6. Actions (Functions)
    1. Call Jobs in same File
    2. Call External Actions with paramters
    3. Use Result of Action into Another
  7. Use Git Secrets
  8. Rest API
  9. Docker
    1. Create env and run scala file
  10. Create Complete Workflow (refer pythonCI.yml)

Format 1 (Call Function)

    name: Test
    on: [workflow_dispatch]
    jobs:
        job1:
           runs-on: [ubuntu-latest]
           steps:
              - name: A
                shell: bash
                run: |
                 echo "Test"
        job2:
         - uses: yml_link@branch
         - with
            arg1: "a"

Create WorkFlow

Method 1:

Git Repo > Actions > Ck on Simple Worflow (this automatically creates folder structure)

Method 2

  • Manually Create root/.github/workflows/
  • Add yaml here

Structure

  • Workflow > Jobs (VM) > Steps > command , Actions(functions)

Rules

  • All Jobs in a file run parallely by default
  • To create sequence - Dependency "needs: [job_name] "
  • Workflows run inside git-hosted / self-hosted Vm
  • By Default the current repository is not checked out.
  • Events Eg: on: [workflow_dispatch] #manual , [push]
  • "_" instead of "-"
  • By default all yaml files gets executed in worklow folder
  • Vm has Python and Docker Pre-Installed
  • Has Docker Installed

Events (on)

  • ref link

  • workflow

  • [push,pull_request,workflow_dispatch] #workflow_dispatch = manual trigger

  • push: branches, tags , path , branches_ignore, tags_ignore , paths_ignore

  • some activites have many activities types

      name:
      on:
        push:
         branches: [master,'branch*']
        pull_request:
          types: [closed ,assigned]
    
  • repository_dispatch (using REST API)

      name:
      on:
        repository_dispatch:
          types: [startme]
    
      # in Postman / curl      
      curl --location --request POST 'https://api.github.com/repos/j-thepac/gitactions/dispatches' \
      --header 'Accept: application/vnd.github+json' \
      --header 'Content: application/json' \
      --header 'Authorization: Bearer generate_personal_token' \
      --header 'Content-Type: application/json' \
      --data-raw '{
          "event_type": "startme"
      }'
    

Actions (Functions)

  • Can reference :

    • In Same File
    • Same Repo
    • Different Repo
  • Different Repo

    • copy title of the git repo or from url ie., account/repo_name
    • "uses: account/repo_name@branch"
    • "uses: account/repo_name@v1"
    • "uses: account/repo_name@commit"
  • With : Provide input

     with:
      varName: value
    

Python

  • add "shell: python"

GIT Environment Variables

echo $GITHUB_SHA
echo $GITHUB_REPOSITORY
echo $GITHUB_WORKSPACE
#github is an object existing environment
echo "${{github.token}}"

Custom Variables

    env:
      key: Value
      
   echo ${{env.key}}  #access

Access Secrets

    echo "${{secrets.KEY}}"

Basic Steps in a Workflow

  • Set Up Env
  • Checkout Code
  • install Dependencies
  • Verify Formatting
  • (Build Project if Necessary)
  • Run Automatd Tests
  • Upload Code Coverage as Artifact
  • Cache Dependencies
  • On Failure , Send message , Mail

CODEOWNERS

  • create file CODEOWNERS

      * @usernsme
      *.py @usrname 
    

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.