-
Notifications
You must be signed in to change notification settings - Fork 40
[WIP] Implement Github Actions CI/CD Pipeline #465
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
maheshkasabe
wants to merge
20
commits into
Murali-group:master
Choose a base branch
from
maheshkasabe:actions-pipeline
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 16 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
efa207d
Fixed bootstrap table not showing and other minor bugs
maheshkasabe e258f1e
Added Local dockerfile & docker-compose support
maheshkasabe 0b93870
Added enviornment variables inside docker-compose setup and developme…
maheshkasabe d292024
Added an ECR Build & Deploy workflow
maheshkasabe efee21f
Added elasticsearch support for docker-compose file & deploy workflow
maheshkasabe 6cfc7b0
Added environment variable support for production file
maheshkasabe 9d1336b
Some additions to Production file
maheshkasabe 9249d89
Added some comments for better understanding
maheshkasabe f8ce6e9
Added some extra workflows for quality & labeling
maheshkasabe cc653d8
Removed docker-compose volume to install bower compoenents
maheshkasabe 20fa485
updated postgres version and added libpq-dev package
maheshkasabe acf602b
Mac docker install issues resolved
maheshkasabe 0c5b156
Added Trivy Scanner
maheshkasabe 2910aba
Added some extra imporvements
maheshkasabe c815599
Added dockerhub ci workflow
maheshkasabe 95d2d23
Added workflow rule to push image only on merging to master branch
maheshkasabe a41879e
Added Comments
maheshkasabe 7ca2918
Added some more comments
maheshkasabe 4f4cb0f
added a actions-pipeline inside pr-labeler.yml
maheshkasabe 55c9812
Renamed workflow
maheshkasabe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # Set to true to add reviewers to pull requests | ||
| addReviewers: true | ||
|
|
||
| # Set to true to add assignees to pull requests | ||
| addAssignees: false | ||
|
|
||
| # A list of reviewers to be added to pull requests (GitHub user name) | ||
| reviewers: | ||
| - maheshkasabe | ||
| - mrhacker4657 | ||
|
|
||
| # A number of reviewers added to the pull request | ||
| # Set 0 to add all the reviewers (default: 0) | ||
| numberOfReviewers: 0 | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| feature: ['feature/*', 'feat/*'] | ||
| fix: fix/* | ||
| chore :hammer:: chore/* |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| name: Trivy Docker Image Scan | ||
|
|
||
| on: [push, pull_request] | ||
|
|
||
| jobs: | ||
| build: | ||
| name: Build | ||
| runs-on: ubuntu-20.04 | ||
| steps: | ||
maheshkasabe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - name: Checkout code | ||
| uses: actions/checkout@v2 | ||
|
|
||
| - name: Build an image from Dockerfile | ||
| run: docker build -t docker.io/my-organization/my-app:${{ github.sha }} . | ||
|
|
||
| - name: Run Trivy vulnerability scanner | ||
| uses: aquasecurity/trivy-action@master | ||
| with: | ||
| image-ref: 'docker.io/my-organization/my-app:${{ github.sha }}' | ||
| format: 'table' | ||
| exit-code: '0' | ||
| ignore-unfixed: true | ||
| vuln-type: 'os,library' | ||
| severity: 'CRITICAL,HIGH' | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| name: 'Auto Assign' | ||
| on: | ||
| pull_request_target: | ||
| types: [opened, ready_for_review] | ||
|
|
||
| jobs: | ||
maheshkasabe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| add-reviews: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: kentaro-m/[email protected] | ||
| with: | ||
| configuration-path: '.github/auto_assign.yml' # Only needed if you use something other than .github/auto_assign.yml | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| name: PR Labeler | ||
| on: pull_request_target | ||
|
|
||
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| pr-labeler: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: branch-label | ||
| uses: TimonVS/pr-labeler-action@v4 | ||
| with: | ||
| repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
| configuration-path: .github/pr-labeler.yml # optional, .github/pr-labeler.yml is the default value | ||
|
|
||
| - name: size-label | ||
| uses: "pascalgn/[email protected]" | ||
| env: | ||
| GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | ||
| with: | ||
| sizes: > | ||
| { | ||
| "0": "XS", | ||
| "20": "S", | ||
| "50": "M", | ||
| "200": "L", | ||
| "800": "XL", | ||
| "2000": "XXL" | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| name: Docker Build & Push Graphspace | ||
|
|
||
| on: [push, pull_request] | ||
|
|
||
| jobs: | ||
|
|
||
| build: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v3 | ||
|
|
||
| - name: login to docker hub | ||
| uses: docker/login-action@v2 | ||
| with: | ||
| username: ${{ secrets.DOCKER_USERNAME }} | ||
| password: ${{ secrets.DOCKER_TOKEN }} | ||
|
|
||
| - name: Set outputs | ||
| id: vars | ||
| if: ${{ github.ref == 'refs/heads/master' }} | ||
| run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | ||
maheshkasabe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| - name: create image | ||
| run: docker build -t graphspace . | ||
|
|
||
| - name: push image | ||
| if: ${{ github.ref == 'refs/heads/master' }} | ||
| run: | | ||
| docker tag graphspace maheshkasbe/graphspace:${{ steps.vars.outputs.sha_short }} | ||
| docker tag graphspace maheshkasbe/graphspace:latest | ||
| docker push maheshkasbe/graphspace:latest | ||
| docker push maheshkasbe/graphspace:${{ steps.vars.outputs.sha_short }} | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| name: Push to ECR | ||
|
|
||
| on: [push, pull_request] | ||
|
|
||
| jobs: | ||
maheshkasabe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| deploy: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
|
|
||
| - name: Check out code | ||
| uses: actions/checkout@v2 | ||
|
|
||
| - name: Build the Docker-compose file | ||
| run: docker-compose -f "docker-compose.yaml" up -d --build | ||
|
|
||
| - name: Show containers | ||
| run: docker ps -a | ||
|
|
||
| - name: Configure AWS credentials | ||
| if: ${{ github.ref == 'refs/heads/master' }} | ||
| uses: aws-actions/configure-aws-credentials@v1 | ||
| with: | ||
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
| aws-region: us-east-1 | ||
|
|
||
| - name: Login to Amazon ECR | ||
| if: ${{ github.ref == 'refs/heads/master' }} | ||
| id: login-ecr | ||
| uses: aws-actions/amazon-ecr-login@v1 | ||
| with: | ||
| registry-type: public | ||
|
|
||
| - name: Set outputs | ||
| id: vars | ||
maheshkasabe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if: ${{ github.ref == 'refs/heads/master' }} | ||
| run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Build, tag, and push image to Amazon ECR | ||
| if: ${{ github.ref == 'refs/heads/master' }} | ||
| env: | ||
| ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | ||
| REGISTRY_ALIAS: ${{ secrets.AWS_REGISTRY_ALIAS }} | ||
| ECR_REPOSITORY: ${{ secrets.AWS_ECR_REPOSITORY }} | ||
| IMAGE_TAG: ${{ steps.vars.outputs.sha_short }} | ||
| run: | | ||
| docker build -t $ECR_REGISTRY/$REGISTRY_ALIAS/$ECR_REPOSITORY:$IMAGE_TAG . | ||
| docker push $ECR_REGISTRY/$REGISTRY_ALIAS/$ECR_REPOSITORY:$IMAGE_TAG | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| name: Labeling new issue | ||
| on: | ||
| issues: | ||
| types: ['opened','edited'] | ||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: Renato66/auto-label@v2 | ||
| with: | ||
| repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
| ignore-comments: true | ||
| labels-synonyms: '{"bug":["error","need fix","not working"],"enhancement":["upgrade"],"question":["help"]}' | ||
| labels-not-allowed: '["good first issue"]' |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| FROM ubuntu:18.04 | ||
| WORKDIR /app | ||
| RUN apt-get -y update && apt-get install -y \ | ||
maheshkasabe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| npm \ | ||
| git \ | ||
| libpq-dev \ | ||
| libxml2 \ | ||
| libxslt-dev | ||
| RUN npm install bower -g | ||
| RUN apt-get install -y python-pip && pip install --upgrade pip | ||
| COPY . /app | ||
| RUN pip install -r requirements.txt | ||
| RUN sh install.sh | ||
| EXPOSE 8000 | ||
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| #!bin/sh | ||
| echo "enabling pg_trgm & btree_gin on database $POSTGRES_DB" | ||
| psql -U $POSTGRES_USER --dbname="$POSTGRES_DB" <<-'EOSQL' | ||
| create extension if not exists pg_trgm; | ||
| create extension if not exists btree_gin; | ||
| EOSQL | ||
| echo "finished with exit code $?" |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| version: "3.4" | ||
| services: | ||
| graphspace: | ||
| restart: always | ||
| stdin_open: true # docker run -i | ||
| tty: true # docker run -t | ||
| build: | ||
| context: . | ||
| ports: | ||
| - "8000:8000" | ||
| env_file: | ||
| - ./secrets.env | ||
| command: > | ||
| sh -c "python manage.py migrate && | ||
| python manage.py runserver" |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| version: "3.4" | ||
| services: | ||
| db: | ||
| image: postgres:9.6 | ||
| restart: always | ||
| environment: | ||
| POSTGRES_DB: graphspace | ||
| POSTGRES_USER: postgres | ||
| POSTGRES_PASSWORD: postgres | ||
| ports: | ||
| - "5432:5432" | ||
| volumes: | ||
| - pgdata:/var/lib/PostgreSQL/data | ||
| - ./db.sh:/docker-entrypoint-initdb.d/create_extensions.sh | ||
|
|
||
| elasticsearch: | ||
| restart: always | ||
| image: docker.elastic.co/elasticsearch/elasticsearch:7.5.2 | ||
| ports: | ||
| - "9200:9200" | ||
| environment: | ||
| - discovery.type=single-node | ||
| volumes: | ||
| - esdata:/var/lib/elasticsearch/data | ||
|
|
||
| graphspace: | ||
| restart: always | ||
| image: maheshkasbe/graphspace:latest | ||
| environment: | ||
| POSTGRES_HOST: db | ||
| POSTGRES_DB: graphspace | ||
| POSTGRES_USER: postgres | ||
| POSTGRES_PASSWORD: postgres | ||
| stdin_open: true # docker run -i | ||
| tty: true # docker run -t | ||
| # build: | ||
| # context: . | ||
| ports: | ||
| - "8000:8000" | ||
| command: > | ||
| sh -c "python manage.py migrate --settings=graphspace.settings.local && | ||
| python manage.py runserver 0.0.0.0:8000 --settings=graphspace.settings.local" | ||
| depends_on: | ||
| - db | ||
| - elasticsearch | ||
|
|
||
| volumes: | ||
| pgdata: | ||
| esdata: |
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| from graphspace.settings.base import * | ||
|
|
||
| # variables for setting up account through which GraphSpace emails | ||
| EMAIL_HOST = os.environ.get('EMAIL_HOST') | ||
| EMAIL_HOST_USER = os.environ.get('EMAIL_HOST_USER') | ||
| EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_HOST_PASSWORD') | ||
|
|
||
| # If error is thrown, display the error in the browser (ONLY FOR LOCAL MACHINES) | ||
| DEBUG = os.environ.get('DEBUG') | ||
| TEMPLATE_DEBUG = os.environ.get('TEMPLATE_DEBUG') | ||
| MAINTENANCE = os.environ.get('MAINTENANCE') | ||
|
|
||
| # URL through which to access graphspace | ||
| URL_PATH = os.environ.get('URL_PATH') | ||
|
|
||
| # If tracking is enabled for GraphSpace in Google Analytics | ||
| GOOGLE_ANALYTICS_PROPERTY_ID = os.environ.get('GOOGLE_ANALYTICS_PROPERTY_ID') | ||
|
|
||
| # Keys given by creating a requestor account on Amazon Mechanical Turk (https://www.mturk.com/mturk/welcome) | ||
| AWSACCESSKEYID = os.environ.get('AWSACCESSKEYID') | ||
| SECRETKEY = os.environ.get('SECRETKEYOST') | ||
|
|
||
| # Path to GraphSPace | ||
| PATH = os.environ.get('PATH', '/path_to_graphspace') | ||
|
|
||
| # SHOULD NEVER CHANGE THIS VALUE | ||
| SECRET_KEY = os.environ.get('SECRET_KEY') | ||
|
|
||
| # If needing to test on production mturk account (real money) | ||
| # AWS_URL = 'https://mechanicalturk.amazonaws.com' | ||
|
|
||
| # Sandbox (development) MTURK (fake money used) | ||
| AWS_URL = os.environ.get('AWS_URL') | ||
|
|
||
| # To configure the application to use the Console Backend for sending e-mail. It writes e-mails to standard out instead of sending them. | ||
| # http://stackoverflow.com/questions/4642011/test-sending-email-without-email-server | ||
| EMAIL_BACKEND = os.environ.get('EMAIL_BACKEND') | ||
|
|
||
|
|
||
| DATABASES = { | ||
| 'default': { | ||
| 'ENGINE': 'django.db.backends.postgresql_psycopg2', | ||
| 'NAME': os.environ.get('POSTGRES_DB'), | ||
| 'USER': os.environ.get('POSTGRES_USER'), | ||
| 'PASSWORD': os.environ.get('POSTGRES_PASSWORD'), | ||
| 'HOST': os.environ.get('POSTGRES_HOST'), | ||
| 'PORT': os.environ.get('POSTGRES_PORT') | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.