Skip to content

Instantly share code, notes, and snippets.

View nashmaniac's full-sized avatar
😃
Happy Always

Raju Ahmed Shetu nashmaniac

😃
Happy Always
  • KOHO Financial Inc
  • Toronto, Canada
View GitHub Profile
@nashmaniac
nashmaniac / basic-sql-construct.sql
Last active July 28, 2022 04:02
basic-sql-construct
SELECT -- required, contains column names comma separated, if you need everything then use *
FROM -- required, name of the sheet
WHERE -- optional, generally contains the filtering criteria
ORDER BY -- optional, used for sorting. Default is low to high. if high to low needed use `desc`
GROUP BY -- optional, used for pivot table kind of query
HAVING -- optional, filtering on the group by
# contents-truncated
# three job definition
jobs:
health-check-job: # health check job for testing and code formatting check
runs-on: ubuntu-latest # os for running the job
services:
postgres: # we need a postgres docker image to be booted a side car service to run the tests that needs a db
image: postgres
env: # the environment variable must match with app/settings.py if block of DATBASES variable otherwise test will fail due to connectivity issue.
# name of our workflow
name: Django CI/CD Workflow
# triggers for our workflow
on:
# opening a pull request to master and develop branch will be a trigger
pull_request:
branches:
- develop
- master
# name of our workflow
name: Django CI/CD Workflow
# triggers for our workflow
on:
# opening a pull request to master and develop branch will be a trigger
pull_request:
branches:
- develop
- master
# truncated upper definition
# three job definition
jobs:
health-check-job: # health check job for testing and code formatting check
# truncated upper definition
- name: Run Test # running tests
run: pip manage.py test # we intentionally made an error. Instead of python we used pip.
- uses: nashmaniac/create-issue-action
if: ${{ failed() }} # only run when this job is failed.
name: Create Issue Action
name: Test Workflow
on: push
jobs:
first-job:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Run Action
# we can give directory path that contains action.yaml or repo address in username/repository_name@version format
import os
import github
# extracting all the input from environments
title = os.environ['INPUT_TITLE']
token = os.environ['INPUT_TOKEN']
labels = os.environ['INPUT_LABELS']
assignees = os.environ['INPUT_ASSIGNEES']
body = os.environ['INPUT_BODY']
# action will be run in python3 container
FROM python:3
# copying requirements.txt and install the action dependencies
COPY requirements.txt /requirements.txt
RUN pip install -r /requirements.txt
# script.py is the file that will contain the codes that we want to run for this action.
COPY script.py /script.py
# we will just run our script.py as our docker entrypoint by python script.py
CMD ["python", "/script.py"]
# every action has a name
name: Create Issue Action
# description
description: This action creates an issue based on user inputs
# input parameters to be taken from user
inputs:
title: # name of variable. In action script it will be available in workflow as environment variable with name INPUT_TITLE
required: true # required variable possible values are true or false
description: Title of the issue
token: # token variable available in workflow as env var named INPUT_TOKEN
# name of our workflow
name: Django CI/CD Workflow
# triggers for our workflow
on:
# opening a pull request to master and develop branch will be a trigger
pull_request:
branches:
- develop
- master