From df646a0f80c7e0f3e44cd7b27497bd0870f5eb1f Mon Sep 17 00:00:00 2001 From: Stanislaw <62724833+BoberITman@users.noreply.github.com> Date: Fri, 16 Dec 2022 21:46:53 +0100 Subject: [PATCH 1/5] CI/CD --- .github/deploy.yml | 20 ++++++++++++++++++++ Dockerfile | 5 +++++ 2 files changed, 25 insertions(+) create mode 100644 .github/deploy.yml create mode 100644 Dockerfile diff --git a/.github/deploy.yml b/.github/deploy.yml new file mode 100644 index 0000000..e13a5f6 --- /dev/null +++ b/.github/deploy.yml @@ -0,0 +1,20 @@ +name: Deploy + +on: + push: + branches: ['main'] + pull_request: + branches: ['main'] + +jobs: + build: + runs-on: self-hosted + steps: + - uses: actions/checkout@v3 + - name: Build image + run: docker build -t ${{ github.repository }} . + - name: Deploy image + run: | + docker stop ${{ github.event.repository.name }} || true + docker rm ${{ github.event.repository.name }} || true + docker run -d -e "DISCORD_TOKEN=${{ secrets.DISCORD_TOKEN }}" -e "REDIS_TOKEN=${{ secrets.REDIS_TOKEN }}" -e "DATABASE_URL=${{ secrets.DATABASE_URL }}" --restart always --network BOT --name ${{ github.event.repository.name }} ${{ github.repository }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3332c50 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,5 @@ +FROM node:16.10.0 +WORKDIR /app +COPY ./ ./ +RUN npm install +CMD ["npm", "run", "start"] \ No newline at end of file From 27aa0d0cae1a45959b94ed22f46683169dd72914 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Dzioba?= <62724833+BoberITman@users.noreply.github.com> Date: Fri, 16 Dec 2022 21:49:01 +0100 Subject: [PATCH 2/5] Add port --- .github/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/deploy.yml b/.github/deploy.yml index e13a5f6..4a51eb1 100644 --- a/.github/deploy.yml +++ b/.github/deploy.yml @@ -17,4 +17,4 @@ jobs: run: | docker stop ${{ github.event.repository.name }} || true docker rm ${{ github.event.repository.name }} || true - docker run -d -e "DISCORD_TOKEN=${{ secrets.DISCORD_TOKEN }}" -e "REDIS_TOKEN=${{ secrets.REDIS_TOKEN }}" -e "DATABASE_URL=${{ secrets.DATABASE_URL }}" --restart always --network BOT --name ${{ github.event.repository.name }} ${{ github.repository }} + docker run -d -e "DISCORD_TOKEN=${{ secrets.TOKEN }}" --restart always -p 2020:2020 --name ${{ github.event.repository.name }} ${{ github.repository }} From 0fe99e10cfca4439f5bed214da1ab9e63d5abf21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Dzioba?= <62724833+BoberITman@users.noreply.github.com> Date: Fri, 16 Dec 2022 21:49:48 +0100 Subject: [PATCH 3/5] change branch name --- .github/deploy.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/deploy.yml b/.github/deploy.yml index 4a51eb1..a394449 100644 --- a/.github/deploy.yml +++ b/.github/deploy.yml @@ -2,9 +2,9 @@ name: Deploy on: push: - branches: ['main'] + branches: ['master'] pull_request: - branches: ['main'] + branches: ['master'] jobs: build: From abddd180d617c3770bd3416a8e09a8569a20a157 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Dzioba?= <62724833+BoberITman@users.noreply.github.com> Date: Fri, 16 Dec 2022 21:51:12 +0100 Subject: [PATCH 4/5] wrong env --- .github/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/deploy.yml b/.github/deploy.yml index a394449..1c9e91a 100644 --- a/.github/deploy.yml +++ b/.github/deploy.yml @@ -17,4 +17,4 @@ jobs: run: | docker stop ${{ github.event.repository.name }} || true docker rm ${{ github.event.repository.name }} || true - docker run -d -e "DISCORD_TOKEN=${{ secrets.TOKEN }}" --restart always -p 2020:2020 --name ${{ github.event.repository.name }} ${{ github.repository }} + docker run -d -e "TOKEN=${{ secrets.TOKEN }}" --restart always -p 2020:2020 --name ${{ github.event.repository.name }} ${{ github.repository }} From 9adf762b89f9cf590619f80b525183947d9edd67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Dzioba?= <62724833+BoberITman@users.noreply.github.com> Date: Fri, 16 Dec 2022 21:53:38 +0100 Subject: [PATCH 5/5] wrong node in dockerfile --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3332c50..6199b04 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ -FROM node:16.10.0 +FROM node:latest WORKDIR /app COPY ./ ./ RUN npm install -CMD ["npm", "run", "start"] \ No newline at end of file +CMD ["npm", "run", "start"]