Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: CI-CD with GitOps

on:
push:
branches: [devops-test]

jobs:
deploy:
runs-on: ubuntu-latest
env:
IMAGE_NAME: gautamabhis/edutrust-backend

steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Set Image Tag
run: echo "IMAGE_TAG=build-${GITHUB_RUN_NUMBER}" >> $GITHUB_ENV

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and Push Docker Image
run: |
docker build -t $IMAGE_NAME:$IMAGE_TAG .
docker push $IMAGE_NAME:$IMAGE_TAG

- name: Trivy Image Scan
uses: aquasecurity/trivy-action@master
with:
image-ref: $IMAGE_NAME:$IMAGE_TAG
format: 'table'

- name: Update Helm values.yaml
run: |
sed -i "s|tag: .*|tag: \"$IMAGE_TAG\"|" helm/edutrust-chart/values.yaml

- name: Commit and Push Updated Chart
run: |
git config user.name "github-actions"
git config user.email "actions@github.com"
git add charts/my-app/values.yaml
git commit -m "CI: Update image tag to $IMAGE_TAG"
git push
2 changes: 1 addition & 1 deletion server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ app.use(cors(
));
app.use(express.json());
app.get('/', (req, res) => {
res.send('Access Blocked ...');
res.send('Access Blocked for devops test ...');
});

app.use('/api/users/auth',userRoutes);
Expand Down
Loading