refact: slugyfi #1257
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
name: Deploy to EC2 | |
on: | |
push: | |
branches: | |
- "1.x" | |
- "development" | |
workflow_dispatch: | |
jobs: | |
deploy-to-ec2: | |
runs-on: ubuntu-latest | |
environment: ${{ github.ref_name }} | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Copy folder content recursively to remote VM | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.AWS_EC2_HOST }} | |
username: ${{ secrets.AWS_EC2_USERNAME }} | |
key: ${{ secrets.AWS_EC2_PRIVATE_SSH_KEY }} | |
source: . | |
target: ${{ secrets.AWS_EC2_TARGET_DIR }} | |
docker-command: | |
runs-on: ubuntu-latest | |
needs: deploy-to-ec2 | |
environment: ${{ github.ref_name }} | |
steps: | |
- name: executing remote ssh commands using password | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.AWS_EC2_HOST }} | |
username: ${{ secrets.AWS_EC2_USERNAME }} | |
key: ${{ secrets.AWS_EC2_PRIVATE_SSH_KEY }} | |
script: | | |
cd ${{ secrets.AWS_EC2_TARGET_DIR }} | |
if [ "docker-compose.${{ github.ref_name }}.yml" == "docker-compose.1.x.yml" ]; then | |
docker-compose -f docker-compose.${{ github.ref_name }}.yml up -d | |
docker exec -i phpkanvas-ecosystem composer install --no-dev --optimize-autoloader | |
else | |
docker compose -f docker-compose.${{ github.ref_name }}.yml up -d | |
docker exec -i phpkanvas-ecosystem composer install --optimize-autoloader | |
fi | |
docker exec -i phpkanvas-ecosystem php artisan lighthouse:cache | |
docker exec -i phpkanvas-ecosystem php artisan lighthouse:clear-cache all | |
docker exec -i phpkanvas-ecosystem php artisan config:cache | |
docker restart queue-scrapper | |
docker restart queue-scrapper-worker-1 | |
docker restart queue-scrapper-worker-2 | |
docker restart queue-scrapper-worker-3 | |
docker restart queue-scrapper-worker-4 | |
docker restart queue | |
docker restart queue-imports | |
docker restart queue-notifications | |
docker restart queue-social | |
docker restart laravel-scheduler | |
docker restart queue-sync-shopify-queue | |
docker restart queue-sync-shopify-queue-worker-1 | |
docker restart queue-sync-shopify-queue-worker-1 | |
docker restart queue-sync-shopify-queue-worker-2 | |
docker restart queue-scout-worker-1 | |
docker restart queue-scout-worker-2 | |
docker restart queue-scout-worker-3 | |
docker restart queue-workflow-1 | |
docker restart queue-workflow-2 | |
docker restart queue-workflow-3 | |
docker restart batch-logger-queue | |
docker restart queue-user-interactions | |
if [ "docker-compose.${{ github.ref_name }}.yml" == "docker-compose.1.x.yml" ]; then | |
docker restart queue-imports2 | |
docker restart queue2 | |
docker restart queue3 | |
docker restart queue4 | |
docker restart queue5 | |
docker restart queue6 | |
docker restart queue7 | |
docker restart queue8 | |
docker restart queue-workflow-4 | |
fi | |
docker exec -i phpkanvas-ecosystem php artisan octane:reload |