Skip to content

Commit

Permalink
ci: worflow test and docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
tusharbansal22 committed Apr 1, 2024
1 parent 976cdfa commit 003a31e
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/.gitmessage
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Title: Summary, imperative, start upper case, don't end with a period
# No more than 50 chars. #### 50 chars is here: #

# Remember blank line between title and body.

# Body: Explain *what* and *why* (not *how*). Include task ID (Jira issue).
# Wrap at 72 chars. ################################## which is here: #


# At the end: Include Co-authored-by for all contributors.
# Include at least one empty line before it. Format:
# Co-authored-by: name <[email protected]>
#
# How to Write a Git Commit Message:
# https://chris.beams.io/posts/git-commit/
#
# 1. Separate subject from body with a blank line
# 2. Limit the subject line to 50 characters
# 3. Capitalize the subject line
# 4. Do not end the subject line with a period
# 5. Use the imperative mood in the subject line
# 6. Wrap the body at 72 characters
# 7. Use the body to explain what and why vs. how
37 changes: 37 additions & 0 deletions .github/workflows/dev_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Run Tests and Create .env.development

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Install dependencies
run: npm install

- name: Create .env.development file
env:
PORT: ${{ secrets.PORT }}
MONGODB_URI: ${{ secrets.MONGODB_URI }}
NODE_ENV: development
JWT_SECRET: ${{ secrets.JWT_SECRET }}
ORIGIN: "*"
run: |
echo "PORT=${PORT}" >> .env.development
echo "MONGODB_URI=${MONGODB_URI}" >> .env.development
echo "NODE_ENV=${NODE_ENV}" >> .env.development
echo "JWT_SECRET=${JWT_SECRET}" >> .env.development
echo "ORIGIN=${ORIGIN}" >> .env.development
- name: Run Jest tests
run: npm test
43 changes: 43 additions & 0 deletions .github/workflows/docker_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Update docker dev image

on:
push:
branches:
- main

jobs:
build-and-push:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Install dependencies
run: npm install

- name: Create .env.development file
env:
PORT: ${{ secrets.PORT }}
MONGODB_URI: ${{ secrets.MONGODB_URI }}
NODE_ENV: development
JWT_SECRET: ${{ secrets.JWT_SECRET }}
ORIGIN: "*"
run: |
echo "PORT=${PORT}" >> .env.development
echo "MONGODB_URI=${MONGODB_URI}" >> .env.development
echo "NODE_ENV=${NODE_ENV}" >> .env.development
echo "JWT_SECRET=${JWT_SECRET}" >> .env.development
echo "ORIGIN=${ORIGIN}" >> .env.development
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}

- name: Build Docker image
run: docker build -t ${{ secrets.DOCKER_USERNAME }}/swifty-order-service .

- name: Push Docker image
run: docker push ${{ secrets.DOCKER_USERNAME }}/swifty-order-service

0 comments on commit 003a31e

Please sign in to comment.