Skip to content

Commit

Permalink
Init github actions
Browse files Browse the repository at this point in the history
* init: created github actions for docker deploy

* chore: added needs in push_to_registry

* review: changed tsconfig and removed actions_init from actions

---------

Co-authored-by: TakSeBiegam <[email protected]>
  • Loading branch information
TakSeBiegam authored Jan 4, 2024
1 parent 00751da commit 87ba98d
Show file tree
Hide file tree
Showing 5 changed files with 610 additions and 565 deletions.
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
README.md
.gitignore
.git
node_modules
lib
.github
47 changes: 47 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Node.js CI

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: setup-node
uses: actions/setup-node@v1
with:
node-version: 18.14
- name: checkout
uses: actions/checkout@v2
- name: install dependencies
run: npm ci
- name: check build errors
run: npm run build
- name: check test if exsists
run: npm test --if-present
push_to_registry:
name: login, build and push docker image to docker hub
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: create tag
run: echo "CURRENT_DATE=$(date +%s)" >> $GITHUB_ENV
- name: Set env
run: echo "GITHUB_SHA_SHORT=$(echo $GITHUB_SHA | cut -c 1-6)" >> $GITHUB_ENV
- name: Build and push
uses: docker/build-push-action@v5
with:
file: ./Dockerfile
context: .
push: true
tags: arkadiuszkurylo/aexol-shop-backend:${{ env.GITHUB_SHA_SHORT }}-${{ env.CURRENT_DATE }}
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM node:18

WORKDIR /usr/src/app

COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
Loading

0 comments on commit 87ba98d

Please sign in to comment.