diff --git a/.github/workflows/.gitmessage b/.github/workflows/.gitmessage new file mode 100644 index 0000000..b9db723 --- /dev/null +++ b/.github/workflows/.gitmessage @@ -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 +# +# 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 \ No newline at end of file diff --git a/.github/workflows/dev_test.yml b/.github/workflows/dev_test.yml new file mode 100644 index 0000000..64145d7 --- /dev/null +++ b/.github/workflows/dev_test.yml @@ -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 diff --git a/.github/workflows/docker_build.yml b/.github/workflows/docker_build.yml new file mode 100644 index 0000000..4db6d3f --- /dev/null +++ b/.github/workflows/docker_build.yml @@ -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