Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "refactor github actions (#1036)" #1037

Merged
merged 1 commit into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions .github/workflows/.checkout.yml

This file was deleted.

44 changes: 0 additions & 44 deletions .github/workflows/.docker_build_and_push.yml

This file was deleted.

23 changes: 0 additions & 23 deletions .github/workflows/.scp_action.yml

This file was deleted.

19 changes: 0 additions & 19 deletions .github/workflows/.ssh_action.yml

This file was deleted.

70 changes: 54 additions & 16 deletions .github/workflows/build_deploy_backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,43 +13,81 @@ on:
workflow_dispatch:

jobs:
build_and_push:
build:
runs-on: ubuntu-latest
strategy:
matrix:
service: ['web', 'celery', 'media']
steps:
- uses: unstructuredstudio/zubhub/.github/workflows/.checkout.yml@master
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Checkout files
uses: actions/checkout@v2

- name: Build and push django api
id: docker_build_web
uses: docker/build-push-action@v2
with:
context: ./zubhub_backend/
file: ./zubhub_backend/compose/web/prod/Dockerfile
push: true
tags: unstructuredstudio/zubhub-services_web:latest
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}

- name: Build and push celery worker
id: docker_build_celery
uses: docker/build-push-action@v2
with:
context: ./zubhub_backend/
file: ./zubhub_backend/compose/celery/prod/Dockerfile
push: true
tags: unstructuredstudio/zubhub-services_celery:latest
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}

- name: Build and push ${{ matrix.service }}
uses: unstructuredstudio/zubhub/.github/workflows/.docker_build_and_push.yml@master
- name: Build and push media service
id: docker_build_media
uses: docker/build-push-action@v2
with:
context: ./zubhub_backend/
file: ./zubhub_backend/compose/${{ matrix.service }}/prod/Dockerfile
file: ./zubhub_backend/compose/media/prod/Dockerfile
push: true
tags: unstructuredstudio/zubhub-services_${{ matrix.service }}:latest
secrets: inherit
tags: unstructuredstudio/zubhub-services_media:latest
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}

deploy:
needs: build_and_push
needs: build
runs-on: ubuntu-latest

steps:
- uses: unstructuredstudio/zubhub/.github/workflows/.checkout.yml@master
- uses: actions/checkout@v1

- uses: unstructuredstudio/zubhub/.github/workflows/.scp_action.yml@master
- name: Copy file via scp
uses: appleboy/scp-action@master
with:
host: ${{ secrets.DO_BACKEND_HOST }}
username: ${{ secrets.DO_BACKEND_USERNAME }}
key: ${{ secrets.DO_SSHKEY }}
source: "."
target: "/home/zubhub-services/zubhub"
secrets: inherit

- uses: unsctructuredstudio/zubhub/.github/workflows/.ssh_action.yml@master
- name: Executing remote command
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.DO_BACKEND_HOST }}
username: ${{ secrets.DO_BACKEND_USERNAME }}
key: ${{ secrets.DO_SSHKEY }}
script: |
cp /home/zubhub-services/zubhub/zubhub_backend/compose/deploy_backend.sh /home/zubhub-services/
sudo bash /home/zubhub-services/deploy_backend.sh
doctl compute droplet list 'zubhub-services*' > droplets.txt
droplets_count=`wc -l < droplets.txt`
rm droplets.txt
docker service scale zubhub-services_web=$(($droplets_count - 1))
secrets: inherit
4 changes: 2 additions & 2 deletions .github/workflows/build_deploy_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
with:
python-version: "3.x"
- run: |
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/build_deploy_frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v3
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Checkout files
uses: actions/checkout@v4
uses: actions/checkout@v2

- name: Build and push
id: docker_build
uses: docker/build-push-action@v5
uses: docker/build-push-action@v2
with:
context: ./zubhub_frontend/zubhub/
file: ./zubhub_frontend/zubhub/Dockerfile.prod
Expand All @@ -45,7 +45,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v1

- name: Copy file via scp
uses: appleboy/scp-action@master
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/build_locust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v3
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Checkout files
uses: actions/checkout@v4
uses: actions/checkout@v2

- name: Build and push locust
id: docker_build_locust
uses: docker/build-push-action@v5
uses: docker/build-push-action@v2
with:
context: ./locust/
file: ./locust/Dockerfile
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/create_destroy_test_vm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
# See https://stackoverflow.com/questions/74957218/what-is-the-difference-between-pull-request-and-pull-request-target-event-in-git
# See https://dev.to/suzukishunsuke/secure-github-actions-by-pullrequesttarget-641#:~:text=pull_request_target%20is%20one%20of%20the,the%20pull%20request's%20base%20branch.
- name: Checkout source branch
uses: actions/checkout@v4
uses: actions/checkout@v2
with:
ref: ${{ env.CHECKOUT_COMMIT_REF }}
repository: ${{ env.CHECKOUT_REPO }}
Expand Down Expand Up @@ -148,7 +148,7 @@ jobs:
# See https://stackoverflow.com/questions/74957218/what-is-the-difference-between-pull-request-and-pull-request-target-event-in-git
# See https://dev.to/suzukishunsuke/secure-github-actions-by-pullrequesttarget-641#:~:text=pull_request_target%20is%20one%20of%20the,the%20pull%20request's%20base%20branch.
- name: Checkout source branch
uses: actions/checkout@v4
uses: actions/checkout@v2
with:
ref: ${{ env.CHECKOUT_COMMIT_REF }}
repository: ${{ env.CHECKOUT_REPO }}
Expand All @@ -175,20 +175,20 @@ jobs:
EOF

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
uses: docker/setup-buildx-action@v1

- name: Login to DockerHub
uses: docker/login-action@v3
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push ${{ matrix.service }}
id: docker_build
uses: docker/build-push-action@v5
uses: docker/build-push-action@v2
with:
# for frontend, context is ./zubhub_frontend/zubhub/
# for backend services, context is ./zubhub_backend/
Expand Down
28 changes: 14 additions & 14 deletions zubhub_backend/docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,20 +95,20 @@ services:
depends_on:
- rabbitmq

# prometheus:
# image: prom/prometheus
# command:
# - --config.file=/etc/prometheus/prometheus.yml
# deploy:
# replicas: 1
# restart_policy:
# condition: on-failure
# placement:
# max_replicas_per_node: 1
# constraints:
# - "node.role==manager"
# volumes:
# - ./compose/prometheus.yml:/etc/prometheus/prometheus.yml:ro
prometheus:
image: prom/prometheus
command:
- --config.file=/etc/prometheus/prometheus.yml
deploy:
replicas: 1
restart_policy:
condition: on-failure
placement:
max_replicas_per_node: 1
constraints:
- "node.role==manager"
volumes:
- ./compose/prometheus.yml:/etc/prometheus/prometheus.yml:ro

secrets:
zubhub_services_secrets:
Expand Down