-
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 all 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: | ||
| - adbharadwaj # Aditya Bharadwaj | ||
| #(optional) - tmmurali | ||
|
|
||
| # 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,4 @@ | ||
| feature: ['feature/*', 'feat/*'] | ||
| fix: fix/* | ||
| chore: chore/* | ||
| actions-pipeline: actions-pipeline/* |
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] # Runs when the someone pushes changes to branch or creates a pull request | ||
|
|
||
| jobs: | ||
| build: | ||
| name: Build | ||
| runs-on: ubuntu-20.04 | ||
| steps: | ||
| - 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 # Runs the Trivy Vulnerability Scanner and Prints the results | ||
| 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,13 @@ | ||
| name: 'Auto Assign' | ||
| on: | ||
| pull_request_target: | ||
| types: [opened, ready_for_review] # Runs when the someone opens a pull request | ||
|
|
||
| jobs: | ||
maheshkasabe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| add-reviews: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Auto Assign Reviewer # Assigns Reviwer from reviewers list to the Pull Request | ||
| 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: Docker Build & Push Graphspace | ||
|
|
||
| on: [push, pull_request] # Runs when the someone pushes changes to branch or creates a 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 Tag | ||
| 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 Graphspace image | ||
| run: docker build -t graphspace . | ||
|
|
||
| - name: Push image to Dockerhub | ||
| 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] # Runs when the someone pushes changes to branch or creates a 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 Tag | ||
| 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,15 @@ | ||
| name: Labeling new issue | ||
| on: | ||
| issues: | ||
| types: ['opened','edited'] | ||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Issue Label #Labels the issue by the description of the issue | ||
| 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| name: PR Labeler | ||
| on: pull_request_target # Runs when the someone creates a pull request | ||
|
|
||
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| pr-labeler: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: branch-label # Labels the Pull Request by branch name as which branch the pr is raised to | ||
| 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 # Labels the Pull Request by the no of lines of code | ||
| 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
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,31 @@ | ||
| #Base Image to install & Run Graphspace | ||
| FROM ubuntu:18.04 | ||
|
|
||
| #Created a app directory for graphspace | ||
| WORKDIR /app | ||
|
|
||
| #Installs required & dev packages to smoothly install graphspace rquirements on ubuntu and mac as well | ||
| 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 | ||
|
|
||
| #Installs npm globally | ||
| RUN npm install bower -g | ||
|
|
||
| #Installs Pip package and upgrades it | ||
| RUN apt-get install -y python-pip && pip install --upgrade pip | ||
|
|
||
| #Copies whole graphspace project in app directory | ||
| COPY . /app | ||
|
|
||
| #Installs Graphspace requirements | ||
| RUN pip install -r requirements.txt | ||
|
|
||
| #Installs Graphspace | ||
| RUN sh install.sh | ||
|
|
||
| #Exposes the port 8000 to discover graphspace container | ||
| 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,9 @@ | ||
| #!bin/sh | ||
|
|
||
| #connects to the postgres database & creates pg_trgm & btree_gin extensions | ||
| 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,52 @@ | ||
| version: "3.4" | ||
| services: | ||
| #Postgres container with env variables | ||
| 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 Container | ||
| 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 Image with enviornment variables | ||
| 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
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.