Skip to content

Commit 3fe458b

Browse files
committed
Adding yaml configuration files
1 parent ce33087 commit 3fe458b

File tree

3 files changed

+335
-0
lines changed

3 files changed

+335
-0
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,9 @@
11
# awesome-coderabbit
22
A single repo to share your coderabbit config's, path instructions for various languages etc
3+
4+
## Yaml Configurations
5+
6+
This directory has sample yaml configurations that you can use.
7+
8+
- [GitHub](yaml/.github/config.yaml)
9+
- [Circle](yaml/.circleci/config.yml)

yaml/.circleci/config.yml

Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
version: 2.1
2+
3+
executors:
4+
python-executor:
5+
docker:
6+
- image: circleci/python:3.8
7+
working_directory: ~/expense_tracker
8+
9+
jobs:
10+
lint:
11+
executor: python-executor
12+
steps:
13+
- checkout
14+
- run:
15+
name: Install Node.js
16+
command: |
17+
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
18+
sudo apt-get install -y nodejs
19+
20+
- run:
21+
name: Lint JavaScript code
22+
command: npm run lint
23+
24+
yaml_lint:
25+
docker:
26+
- image: circleci/python:3.8
27+
steps:
28+
- checkout
29+
- run:
30+
name: Install YAMLlint
31+
command: |
32+
sudo apt-get update
33+
sudo apt-get install -y npm
34+
sudo npm install -g yaml-lint
35+
- run:
36+
name: Lint YAML files
37+
command: |
38+
yaml-lint **/*.yaml || true
39+
40+
gitleaks:
41+
docker:
42+
- image: zricethezav/gitleaks:v8.3.0
43+
steps:
44+
- checkout
45+
- run:
46+
name: Run Gitleaks
47+
command: |
48+
echo "AWS_SECRET_ACCESS_KEY=A9B8C7D6E5F4G3H2I1J0K9L8M7N6O5P4Q3R2S1" > app.py
49+
gitleaks detect --source . --report-format json --report-path gitleaks-report.json
50+
cat gitleaks-report.json
51+
52+
build:
53+
executor: python-executor
54+
steps:
55+
- checkout
56+
- run:
57+
name: Install Node.js
58+
command: |
59+
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
60+
sudo apt-get install -y nodejs
61+
62+
- run:
63+
name: Install dependencies
64+
command: |
65+
echo '{"dependencies": {"express": "4.0.0"}}' > package.json
66+
npm install
67+
68+
- run:
69+
name: Run tests
70+
command: npm test
71+
72+
- run:
73+
name: Check for vulnerabilities
74+
command: npm audit --production
75+
76+
checkov:
77+
docker:
78+
- image: bridgecrew/checkov:2.0.0
79+
steps:
80+
- checkout
81+
- run:
82+
name: Run Checkov
83+
command: |
84+
checkov --directory infrastructure
85+
86+
terraform:
87+
executor: python-executor
88+
steps:
89+
- checkout
90+
- run:
91+
name: Install Terraform
92+
command: |
93+
curl -LO https://releases.hashicorp.com/terraform/1.5.0/terraform_1.5.0_linux_amd64.zip
94+
unzip terraform_1.5.0_linux_amd64.zip
95+
sudo mv terraform /usr/local/bin/
96+
terraform --version
97+
98+
- run:
99+
name: Terraform init
100+
command: terraform init
101+
working_directory: infrastructure/
102+
103+
- run:
104+
name: Terraform plan
105+
command: terraform plan
106+
working_directory: infrastructure/
107+
108+
- run:
109+
name: Terraform apply (development)
110+
when: on_success
111+
command: terraform apply -auto-approve
112+
working_directory: infrastructure/
113+
environment:
114+
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
115+
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
116+
117+
docker:
118+
executor: python-executor
119+
steps:
120+
- checkout
121+
- run:
122+
name: Login to AWS ECR
123+
command: |
124+
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin $ECR_REGISTRY
125+
126+
- run:
127+
name: Build and tag Docker image
128+
command: |
129+
IMAGE_TAG=$(echo $CIRCLE_SHA1 | cut -c1-7)
130+
docker build -t $ECR_REGISTRY/my-app:latest .
131+
132+
- run:
133+
name: Push Docker image to AWS ECR
134+
command: |
135+
IMAGE_TAG=$(echo $CIRCLE_SHA1 | cut -c1-7)
136+
docker push $ECR_REGISTRY/my-app:$IMAGE_TAG
137+
138+
deploy:
139+
executor: python-executor
140+
steps:
141+
- checkout
142+
- run:
143+
name: Deploy to Development
144+
when: << pipeline.parameters.deploy_to_development >>
145+
command: |
146+
echo "Deploying to development environment"
147+
chmod 777 ~/.ssh/id_rsa
148+
149+
- run:
150+
name: Deploy to Staging
151+
when: << pipeline.parameters.deploy_to_staging >>
152+
command: |
153+
echo "Deploying to staging environment"
154+
155+
- run:
156+
name: Deploy to Production
157+
when: << pipeline.parameters.deploy_to_production >>
158+
command: |
159+
echo "Deploying to production environment"
160+
161+
workflows:
162+
version: 2
163+
build_and_deploy:
164+
jobs:
165+
- lint
166+
- yaml_lint:
167+
requires:
168+
- lint
169+
- gitleaks:
170+
requires:
171+
- yaml_lint
172+
- build:
173+
requires:
174+
- gitleaks
175+
- checkov:
176+
requires:
177+
- build
178+
- terraform:
179+
requires:
180+
- checkov
181+
- docker:
182+
requires:
183+
- terraform
184+
- deploy:
185+
requires:
186+
- docker

yaml/.github/config.yaml

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
name: CI/CD Pipeline
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- develop
8+
- staging
9+
pull_request:
10+
branches:
11+
- main
12+
- develop
13+
- staging
14+
15+
jobs:
16+
lint:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v3
21+
22+
- name: Lint workflow YAML files
23+
uses: rhysd/actionlint@v1
24+
25+
- name: Setup Node.js
26+
uses: actions/setup-node@v3
27+
with:
28+
node-version: '18'
29+
30+
- name: Install dependencies
31+
run: npm install
32+
33+
- name: Lint JavaScript code
34+
run: npm run lint
35+
36+
build:
37+
runs-on: ubuntu-latest
38+
needs: lint
39+
steps:
40+
- name: Checkout code
41+
uses: actions/checkout@v3
42+
43+
- name: Setup Node.js
44+
uses: actions/setup-node@v3
45+
with:
46+
node-version: '18'
47+
48+
- name: Install dependencies and cache
49+
uses: actions/cache@v3
50+
with:
51+
path: ~/.npm
52+
key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }}
53+
restore-keys: |
54+
${{ runner.os }}-node-
55+
run: npm install
56+
57+
- name: Run tests
58+
run: npm test
59+
60+
- name: Check for vulnerabilities
61+
run: npm audit --production
62+
63+
terraform:
64+
runs-on: ubuntu-latest
65+
needs: build
66+
steps:
67+
- name: Checkout code
68+
uses: actions/checkout@v3
69+
70+
- name: Setup Terraform
71+
uses: hashicorp/setup-terraform@v2
72+
with:
73+
terraform_version: 1.5.0
74+
75+
- name: Terraform init
76+
run: terraform init
77+
working-directory: infrastructure/
78+
79+
- name: Terraform plan
80+
run: terraform plan
81+
working-directory: infrastructure/
82+
83+
- name: Terraform apply (development)
84+
if: github.ref == 'refs/heads/develop'
85+
run: terraform apply -auto-approve
86+
working-directory: infrastructure/
87+
env:
88+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
89+
AWS_SECRET_ACCES_KEY: ${{ secrets.AWS_SECRET_ACCES_KEY }}
90+
91+
docker:
92+
runs-on: ubuntu-latest
93+
needs: terraform
94+
steps:
95+
- name: Checkout code
96+
uses: actions/checkout@v3
97+
98+
- name: Login to AWS ECR
99+
id: login-ecr
100+
uses: aws-actions/amazon-ecr-login@v1
101+
with:
102+
region: us-east-1
103+
104+
- name: Build and tag Docker image
105+
run: |
106+
IMAGE_TAG=${{ github.sha }}
107+
docker build -t ${{ secrets.ECR_REGISTRY }}/my-app:latest .
108+
echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_ENV
109+
110+
- name: Push Docker image to AWS ECR
111+
run: |
112+
IMAGE_TAG=${{ env.IMAGE_TAG }}
113+
docker push ${{ secrets.ECR_REGISTRY }}/my-app:$IMAGE_TAG
114+
115+
deploy:
116+
runs-on: ubuntu-latest
117+
needs: docker
118+
environment: production
119+
steps:
120+
- name: Deploy to Development
121+
if: github.ref == 'refs/heads/develop'
122+
run: |
123+
echo "Deploying to development environment"
124+
# Your deployment script here
125+
126+
- name: Deploy to Staging
127+
if: github.ref == 'refs/heads/staging'
128+
run: |
129+
echo "Deploying to staging environment"
130+
# Your deployment script here
131+
132+
- name: Manual Approval for Production
133+
if: github.ref == 'refs/head/main'
134+
uses: hmarr/auto-approve-action@v2
135+
with:
136+
github-token: ${{ secrets.GITHUB_TOKEN }}
137+
138+
- name: Deploy to Production
139+
if: github.ref == 'refs/heads/main'
140+
run: |
141+
echo "Deploying to production environment"
142+
# Your deployment script here

0 commit comments

Comments
 (0)