From f948e021a5638b9bf71b9e2243aeea24f5c0e920 Mon Sep 17 00:00:00 2001 From: 4l3j0Ok Date: Wed, 29 Nov 2023 03:27:00 -0300 Subject: [PATCH 1/5] added name to checkout step --- .github/workflows/build.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 9a244dc..506ab1b 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -9,6 +9,7 @@ jobs: runs-on: ubuntu-latest steps: - + name: Checkout uses: actions/checkout@master - name: Docker login From 51eace76bcc22bfb1c3198eb24bc625ef1342818 Mon Sep 17 00:00:00 2001 From: 4l3j0Ok Date: Wed, 29 Nov 2023 03:31:11 -0300 Subject: [PATCH 2/5] deploy workflow --- .github/workflows/deploy.yaml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/deploy.yaml diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml new file mode 100644 index 0000000..1140794 --- /dev/null +++ b/.github/workflows/deploy.yaml @@ -0,0 +1,22 @@ +name: deploy +on: + push: + tags: + - "v*" + +jobs: + deploy: + runs-on: ubuntu-latest + + steps: + - name: Configurar clave SSH + uses: webfactory/ssh-agent@v0.8.0 + with: + ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} + + - name: Clonar repositorio + uses: actions/checkout@v2 + + - name: Desplegar a servidor + run: | + ssh ${{ secrets.PROD_USERNMAE }}@${{ secrets.PROD_HOST}} "cd ${{ secrets.PROD_APP_PATH }} && docker-compose down --remove-orphans && docker-compose pull && docker-compose up -d" From 05cf1f8d8f6e9d22e4d7011792e3c58283f6bbaa Mon Sep 17 00:00:00 2001 From: 4l3j0Ok Date: Thu, 30 Nov 2023 00:43:46 -0300 Subject: [PATCH 3/5] updated compose --- deploy/docker-compose.yml | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/deploy/docker-compose.yml b/deploy/docker-compose.yml index 7ffecf6..7ab6592 100755 --- a/deploy/docker-compose.yml +++ b/deploy/docker-compose.yml @@ -2,20 +2,16 @@ version: "3.9" services: backend: - image: alejoide/bcra-scraper-api:1.0.2 - restart: on-failure - ports: - - 8080:8080 + image: alejoide/bcra-scraper-api:latest + restart: unless-stopped depends_on: - mongo env_file: - backend.env - volumes: - - ../backend/src:/app/src mongo: image: mongo:6.0.8 - restart: on-failure + restart: unless-stopped env_file: - mongo.env volumes: From b9ec1769e732522c8f7067413d01a589599b602b Mon Sep 17 00:00:00 2001 From: 4l3j0Ok Date: Thu, 30 Nov 2023 00:45:36 -0300 Subject: [PATCH 4/5] runs-on runner --- .github/workflows/build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 506ab1b..299ca52 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -6,7 +6,7 @@ on: jobs: build: environment: prod - runs-on: ubuntu-latest + runs-on: prod steps: - name: Checkout From 9d2366ee637fab616329008dd68edc8cfa2ca8d2 Mon Sep 17 00:00:00 2001 From: 4l3j0Ok Date: Thu, 30 Nov 2023 00:46:10 -0300 Subject: [PATCH 5/5] deploy action --- .github/workflows/deploy.yaml | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 1140794..fd7d12b 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -6,17 +6,20 @@ on: jobs: deploy: - runs-on: ubuntu-latest - + name: Deploy to production + runs-on: prod steps: - - name: Configurar clave SSH - uses: webfactory/ssh-agent@v0.8.0 - with: - ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} - - - name: Clonar repositorio - uses: actions/checkout@v2 - - - name: Desplegar a servidor - run: | - ssh ${{ secrets.PROD_USERNMAE }}@${{ secrets.PROD_HOST}} "cd ${{ secrets.PROD_APP_PATH }} && docker-compose down --remove-orphans && docker-compose pull && docker-compose up -d" + - + name: Checkout + uses: actions/checkout@master + - + name: Copy docker-compose.yaml + run: | + cp -f ./deploy/docker-compose.yaml ${{ PROJECT_PATH }}/docker-compose.yaml + - + name: Pull changes and restart + run: | + cd ${{ PROJECT_PATH }} + docker-compose down --remove-orphans + docker-compose pull + docker-compose up -d