Refer /.github/workflows/ for code
- Format
- Events
- Jobs
- Steps vs Actions
- Steps-
- Change Shell
- Run - python , shell
- Run Git string operations
- if Condition
- Use Variables
- Use sh file
- Error handling
- Actions (Functions)
- Call Jobs in same File
- Call External Actions with paramters
- Use Result of Action into Another
- Use Git Secrets
- Rest API
- Docker
- Create env and run scala file
- Create Complete Workflow (refer pythonCI.yml)
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"
Git Repo > Actions > Ck on Simple Worflow (this automatically creates folder structure)
- Manually Create root/.github/workflows/
- Add yaml here
- Workflow > Jobs (VM) > Steps > command , Actions(functions)
- 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
-
[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" }'
-
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
- add "shell: python"
echo $GITHUB_SHA
echo $GITHUB_REPOSITORY
echo $GITHUB_WORKSPACE
#github is an object existing environment
echo "${{github.token}}"
env:
key: Value
echo ${{env.key}} #access
echo "${{secrets.KEY}}"
- 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
-
create file CODEOWNERS
* @usernsme *.py @usrname