-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit bbf14fa
Showing
56 changed files
with
9,225 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,134 @@ | ||
name: CD - Deploy Backend | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- backend/** | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
services: | ||
postgres: | ||
image: postgres:15.4 | ||
env: | ||
POSTGRES_USER: shreyas | ||
POSTGRES_PASSWORD: password | ||
POSTGRES_DB: customer | ||
ports: | ||
- 5432:5432 | ||
options: | ||
--health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
defaults: | ||
run: | ||
working-directory: ./backend | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: First message when CD workflow starts | ||
run: > | ||
curl -X POST -H 'Content-type: application/json' | ||
--data '{"text":":start: :nyancat_big: Starting..... :cool-doge:"}' | ||
${{ secrets.SLACK_WEBHOOK_URL }} | ||
- name: Send Slack Commit Message And SHA | ||
run: > | ||
curl -X POST -H 'Content-type: application/json' | ||
--data '{"text":":github: https://github.com/shreyas957/Spring-Boot-Full-Stack-Professional/commit/${{ github.sha }} - ${{ github.event.head_commit.message }}"}' | ||
${{ secrets.SLACK_WEBHOOK_URL }} | ||
- name: Send Slack Message | ||
run: > | ||
curl -X POST -H 'Content-type: application/json' | ||
--data '{"text":"Deployment started :progress_bar: :fingerscrossed:"}' | ||
${{ secrets.SLACK_WEBHOOK_URL }} | ||
- uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'temurin' | ||
java-version: '17' | ||
cache: 'maven' | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }} | ||
|
||
- name: Set build number | ||
id: build-number | ||
run: echo "BUILD_NUMBER=$(date '+%d.%m.%Y.%H.%M.%S')" >> $GITHUB_OUTPUT | ||
|
||
- name: Send Slack Message | ||
run: > | ||
curl -X POST -H 'Content-type: application/json' | ||
--data '{"text":":maven: Building with Maven"}' | ||
${{ secrets.SLACK_WEBHOOK_URL }} | ||
- name: Build Package Push with Maven | ||
run: mvn -ntp -B verify -D docker.image.tag=${{steps.build-number.outputs.BUILD_NUMBER}} jib:build | ||
|
||
- name: Send Slack Message | ||
run: > | ||
curl -X POST -H 'Content-type: application/json' | ||
--data '{"text":":docker: Image tag:${{ steps.build-number.outputs.BUILD_NUMBER }} pushed to DockerHub - https://hub.docker.com/repository/docker/shreyas957/shreyas-spring-boot-full-stack-api/"}' | ||
${{ secrets.SLACK_WEBHOOK_URL }} | ||
- name: Update Dockerrun.aws.json api image tag with new build number | ||
run: | | ||
echo "Dockerrun.aws.json before updating tag" | ||
cat Dockerrun.aws.json | ||
sed -i -E 's_(shreyas957/shreyas-full-stack-professional-api:)([^"]*)_\1'${{steps.build-number.outputs.BUILD_NUMBER}}'_' Dockerrun.aws.json | ||
echo "Dockerrun.aws.json after updating tag" | ||
cat Dockerrun.aws.json | ||
- name: Send Slack Message | ||
run: > | ||
curl -X POST -H 'Content-type: application/json' | ||
--data '{"text":":aws: Starting Deployment to Elastic Beanstalk :progress_bar:"}' | ||
${{ secrets.SLACK_WEBHOOK_URL }} | ||
- name: Deploy to Elastic Beanstalk | ||
uses: einaregilsson/beanstalk-deploy@v21 | ||
with: | ||
aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
application_name: ${{ secrets.EB_APPLICATION_NAME }} | ||
environment_name: ${{ secrets.EB_ENVIRONMENT_NAME }} | ||
version_label: ${{ steps.build-number.outputs.BUILD_NUMBER }} | ||
version_description: ${{ github.SHA }} | ||
region: ${{ secrets.EB_REGION }} | ||
deployment_package: backend/Dockerrun.aws.json | ||
|
||
- name: Send Slack Message | ||
run: > | ||
curl -X POST -H 'Content-type: application/json' | ||
--data '{"text":":githubloading: Committing to repo https://github.com/shreyas957/Spring-Boot-Full-Stack-Professional/"}' | ||
${{ secrets.SLACK_WEBHOOK_URL }} | ||
- name: commit and push Dockerrun.aws.json | ||
run: | | ||
git config user.name github-actions | ||
git config user.email [email protected] | ||
git add . | ||
git commit -m "Update Dockerrun.aws.json docker image with new tag ${{ steps.build-number.outputs.BUILD_NUMBER }}" | ||
git push | ||
- name: Send Slack Message | ||
run: > | ||
curl -X POST -H 'Content-type: application/json' | ||
--data '{"text":"Deployment and commit completed :github-check-mark: :party_blob:"}' | ||
${{ secrets.SLACK_WEBHOOK_URL }} | ||
- name: Send Slack Message | ||
if: always() | ||
run: > | ||
curl -X POST -H 'Content-type: application/json' | ||
--data '{"text":"Job Status ${{ job.status }}"}' | ||
${{ secrets.SLACK_WEBHOOK_URL }} |
This file contains 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,39 @@ | ||
name: CI - Build Backend | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
paths: | ||
- backend/** | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
services: | ||
postgres: | ||
image: postgres:15.4 | ||
env: | ||
POSTGRES_USER: shreyas | ||
POSTGRES_PASSWORD: password | ||
POSTGRES_DB: customer | ||
ports: | ||
- 5432:5432 | ||
options: >- | ||
--health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
defaults: | ||
run: | ||
working-directory: ./backend | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'temurin' | ||
java-version: '17' | ||
cache: 'maven' | ||
- name: Build and run Unit/Integration Tests with Maven | ||
run: mvn -ntp -B verify |
This file contains 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 @@ | ||
**/target/ | ||
**/.idea/ | ||
**/node_modules/ | ||
**/.DS_Store | ||
**/*.iml | ||
|
||
# Javascript | ||
|
||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
dist | ||
dist-ssr | ||
*.local | ||
|
||
# Editor directories and files | ||
.vscode/* | ||
!.vscode/extensions.json | ||
.idea | ||
.DS_Store | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? |
This file contains 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 @@ | ||
# Spring-Boot-Full-Stack |
This file contains 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,23 @@ | ||
{ | ||
"AWSEBDockerrunVersion": 2, | ||
"containerDefinitions": [ | ||
{ | ||
"name": "shreyas-full-stack-professional-api", | ||
"image": "shreyas957/shreyas-full-stack-professional-api:15.11.2023.12.48.00", | ||
"essential": true, | ||
"memory": 512, | ||
"portMappings": [ | ||
{ | ||
"hostPort": 80, | ||
"containerPort": 8080 | ||
} | ||
], | ||
"environment": [ | ||
{ | ||
"name": "SPRING_DATASOURCE_URL", | ||
"value": "jdbc:postgresql://awseb-e-c53iftxnsa-stack-awsebrdsdatabase-ewqb9owr5101.cm3o7uhddx0b.ap-south-1.rds.amazonaws.com:5432/customer" | ||
} | ||
] | ||
} | ||
] | ||
} |
Oops, something went wrong.