-
Notifications
You must be signed in to change notification settings - Fork 399
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #92 from WildCodeSchool/dev
Dev
- Loading branch information
Showing
43 changed files
with
18,357 additions
and
5,732 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: CD-traefik | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
types: [closed] | ||
|
||
jobs: | ||
lint: | ||
uses: ./.github/workflows/_lint.yml | ||
permissions: | ||
checks: write | ||
contents: write | ||
|
||
check-secrets: | ||
needs: lint | ||
if: (github.event.pull_request.merged || github.event_name == 'push') | ||
runs-on: ubuntu-latest | ||
outputs: | ||
caprover-server: ${{ steps.caprover-server.outputs.defined }} | ||
steps: | ||
- name: Check for secrets availability | ||
id: defined | ||
# perform secret check & put boolean result as an output | ||
shell: bash | ||
run: | | ||
if [ "${{ secrets.SSH_USER }}" != '' && "${{ secrets.SSH_HOST }}" != '' && "${{ secrets.SSH_PASSWORD }}" != '' ]; then | ||
echo "defined=true" >> $GITHUB_OUTPUT; | ||
else | ||
echo "defined=false" >> $GITHUB_OUTPUT; | ||
fi | ||
deploy: | ||
needs: check-secrets | ||
if: needs.check-secrets.outputs.defined == 'true' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Deploy to VPS | ||
uses: appleboy/ssh-action@master | ||
with: | ||
username: ${{ secrets.SSH_USER }} | ||
host: ${{ secrets.SSH_HOST }} | ||
password: ${{ secrets.SSH_PASSWORD }} | ||
script: cd && cd traefik/deploy && bash ./js-project.sh ${{ github.actor }} ${{ github.event.repository.name }} ${{ vars.PROJECT_NAME }} '${{ toJSON(vars) }}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,6 @@ | ||
name: dev | ||
|
||
on: | ||
push: | ||
branches: | ||
- develop | ||
- dev | ||
pull_request: | ||
branches: | ||
- develop | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: Remove-from-Traefik | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Remove from VPS | ||
uses: appleboy/ssh-action@master | ||
with: | ||
username: ${{ secrets.SSH_USER }} | ||
host: ${{ secrets.SSH_HOST }} | ||
password: ${{ secrets.SSH_PASSWORD }} | ||
script: cd && cd traefik/deploy && bash ./remove-project.sh ${{ github.event.repository.name }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
node_modules | ||
.yarn | ||
node_modules | ||
.DS_Store | ||
.idea | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Dockerfile backend | ||
FROM node:16.14 | ||
|
||
WORKDIR /usr/src/app | ||
|
||
COPY ./ . | ||
|
||
RUN npm install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
node_modules | ||
coverage | ||
.env |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Get variables from .env file for database connection | ||
const { DB_HOST, DB_PORT, DB_USER, DB_PASSWORD, DB_NAME } = process.env; | ||
|
||
// Create a connection pool to the database | ||
const mysql = require("mysql2/promise"); | ||
|
||
const client = mysql.createPool({ | ||
host: DB_HOST, | ||
port: DB_PORT, | ||
user: DB_USER, | ||
password: DB_PASSWORD, | ||
database: DB_NAME, | ||
}); | ||
|
||
// Try to get a connection to the database | ||
client | ||
.getConnection() | ||
.then((connection) => { | ||
console.info(`Using database ${DB_NAME}`); | ||
|
||
connection.release(); | ||
}) | ||
.catch((error) => { | ||
console.warn( | ||
"Warning:", | ||
"Failed to establish a database connection.", | ||
"Please check your database credentials in the .env file if you need a database access." | ||
); | ||
console.error("Error message:", error.message); | ||
}); | ||
|
||
// Store database name into client for further uses | ||
client.databaseName = DB_NAME; | ||
|
||
// Ready to export | ||
module.exports = client; |
Oops, something went wrong.