From aaa6f2a690c4a07cf39843df1b335048ca06a86d Mon Sep 17 00:00:00 2001 From: Khattab Date: Wed, 7 Feb 2024 21:43:36 +0200 Subject: [PATCH 1/4] feature: dockerizing our app, add folder to test out endpoints in --- API TESTING/user.rest | 0 Dockerfile | 13 +++++++++++++ docker-compose.yml | 25 +++++++++++++++++++++++++ 3 files changed, 38 insertions(+) create mode 100644 API TESTING/user.rest create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/API TESTING/user.rest b/API TESTING/user.rest new file mode 100644 index 0000000..e69de29 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..55ee6d9 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM node:20.10.0 + +WORKDIR /app + +COPY package.json ./ + +RUN npm install + +COPY . . + +EXPOSE 3000 + +CMD ["npm", "start"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..5cec2c7 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,25 @@ +version: '3.8' + +services: + # Node.js App + node-app: + build: . + ports: + - "3000:3000" + volumes: + - .:/app + environment: + - NODE_ENV=development + - PORT=3000 + command: npm start + +# PostgreSQL Database + postgres: + image: "postgres:latest" + container_name: "postgres" + environment: + POSTGRES_USER: "postgres" + POSTGRES_PASSWORD: "postgres" + POSTGRES_DB: "postgres" + ports: + - "5432:5432" \ No newline at end of file From 31dfcc93241fed349f8015f9a10bfff488e3270f Mon Sep 17 00:00:00 2001 From: Khattab Date: Fri, 9 Feb 2024 22:03:38 +0200 Subject: [PATCH 2/4] feature(devops-work): add github action to Prevent Direct Pushes to Main --- .github/workflows/prevent-direct-push.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .github/workflows/prevent-direct-push.yml diff --git a/.github/workflows/prevent-direct-push.yml b/.github/workflows/prevent-direct-push.yml new file mode 100644 index 0000000..92e6519 --- /dev/null +++ b/.github/workflows/prevent-direct-push.yml @@ -0,0 +1,19 @@ +name: Prevent Direct Pushes to Main + +on: + push: + branches: + - main + +jobs: + prevent_direct_push: + runs-on: ubuntu-latest + + steps: + - name: Check if push is direct to main and not a force push + if: > + github.ref == 'refs/heads/main' && + github.event_name == 'push' && + github.event.pull_request == null && + github.event.head_commit != null + run: exit 1 # Exit with an error code to fail the workflow From ae72bedb655f5eb05111031071d23c452e122fb0 Mon Sep 17 00:00:00 2001 From: Mohamed Khattab <91610279+Mohamed-khattab@users.noreply.github.com> Date: Fri, 9 Feb 2024 22:11:30 +0200 Subject: [PATCH 3/4] Update prevent-direct-push.yml --- .github/workflows/prevent-direct-push.yml | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/workflows/prevent-direct-push.yml b/.github/workflows/prevent-direct-push.yml index 92e6519..11b3e97 100644 --- a/.github/workflows/prevent-direct-push.yml +++ b/.github/workflows/prevent-direct-push.yml @@ -1,4 +1,4 @@ -name: Prevent Direct Pushes to Main +name: Enforce Policy for Main Branch on: push: @@ -6,14 +6,13 @@ on: - main jobs: - prevent_direct_push: + enforce_policy: runs-on: ubuntu-latest - steps: - - name: Check if push is direct to main and not a force push + - name: Check if push is to main and force push if: > - github.ref == 'refs/heads/main' && - github.event_name == 'push' && - github.event.pull_request == null && - github.event.head_commit != null + github.ref == 'refs/heads/main' && + github.event_name == 'push' && + github.event.pull_request == null && + !contains(github.event.head_commit.message, '[force]') run: exit 1 # Exit with an error code to fail the workflow From 230ca52e6363fbfac17774ad9de7c0c4cc9828cf Mon Sep 17 00:00:00 2001 From: Mohamed Khattab <91610279+Mohamed-khattab@users.noreply.github.com> Date: Fri, 9 Feb 2024 22:16:03 +0200 Subject: [PATCH 4/4] Update prevent-direct-push.yml --- .github/workflows/prevent-direct-push.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/prevent-direct-push.yml b/.github/workflows/prevent-direct-push.yml index 11b3e97..8baf8e2 100644 --- a/.github/workflows/prevent-direct-push.yml +++ b/.github/workflows/prevent-direct-push.yml @@ -15,4 +15,6 @@ jobs: github.event_name == 'push' && github.event.pull_request == null && !contains(github.event.head_commit.message, '[force]') - run: exit 1 # Exit with an error code to fail the workflow + run: + echo "Warning: Direct pushes to the main branch without force are not recommended. Please use pull requests for code review." + exit 1