Compare commits
2 Commits
7fe1b89f5b
...
56811f0ecb
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
56811f0ecb | ||
|
|
bf28157423 |
61
.github/workflows/deploy.yml
vendored
61
.github/workflows/deploy.yml
vendored
@ -10,12 +10,36 @@ jobs:
|
|||||||
name: Build and Push to Docker Hub
|
name: Build and Push to Docker Hub
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
|
web_changed: ${{ steps.changes.outputs.web_changed }}
|
||||||
|
bot_changed: ${{ steps.changes.outputs.bot_changed }}
|
||||||
|
cache_proxy_changed: ${{ steps.changes.outputs.cache_proxy_changed }}
|
||||||
web_tag: ${{ steps.vars.outputs.web_tag }}
|
web_tag: ${{ steps.vars.outputs.web_tag }}
|
||||||
bot_tag: ${{ steps.vars.outputs.bot_tag }}
|
bot_tag: ${{ steps.vars.outputs.bot_tag }}
|
||||||
cache_proxy_tag: ${{ steps.vars.outputs.cache_proxy_tag }}
|
cache_proxy_tag: ${{ steps.vars.outputs.cache_proxy_tag }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 2 # нужно, чтобы сравнивать с предыдущим коммитом
|
||||||
|
|
||||||
|
- name: Detect changed directories
|
||||||
|
id: changes
|
||||||
|
run: |
|
||||||
|
echo "web_changed=false" >> $GITHUB_OUTPUT
|
||||||
|
echo "bot_changed=false" >> $GITHUB_OUTPUT
|
||||||
|
echo "cache_proxy_changed=false" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
git diff --name-only HEAD~1 HEAD > changed_files.txt
|
||||||
|
|
||||||
|
if grep -q '^apps/web/' changed_files.txt; then
|
||||||
|
echo "web_changed=true" >> $GITHUB_OUTPUT
|
||||||
|
fi
|
||||||
|
if grep -q '^apps/bot/' changed_files.txt; then
|
||||||
|
echo "bot_changed=true" >> $GITHUB_OUTPUT
|
||||||
|
fi
|
||||||
|
if grep -q '^apps/cache-proxy/' changed_files.txt; then
|
||||||
|
echo "cache_proxy_changed=true" >> $GITHUB_OUTPUT
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Create fake .env file for build
|
- name: Create fake .env file for build
|
||||||
run: |
|
run: |
|
||||||
@ -42,27 +66,36 @@ jobs:
|
|||||||
- name: Login to Docker Hub
|
- name: Login to Docker Hub
|
||||||
run: echo "${{ secrets.DOCKERHUB_TOKEN }}" | docker login -u "${{ secrets.DOCKERHUB_USERNAME }}" --password-stdin
|
run: echo "${{ secrets.DOCKERHUB_TOKEN }}" | docker login -u "${{ secrets.DOCKERHUB_USERNAME }}" --password-stdin
|
||||||
|
|
||||||
|
# ---- Web ----
|
||||||
- name: Build web image
|
- name: Build web image
|
||||||
|
if: steps.changes.outputs.web_changed == 'true'
|
||||||
run: |
|
run: |
|
||||||
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/zapishis-web:${{ steps.vars.outputs.web_tag }} -f ./apps/web/Dockerfile .
|
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/zapishis-web:${{ steps.vars.outputs.web_tag }} -f ./apps/web/Dockerfile .
|
||||||
|
|
||||||
- name: Push web image to Docker Hub
|
- name: Push web image
|
||||||
|
if: steps.changes.outputs.web_changed == 'true'
|
||||||
run: |
|
run: |
|
||||||
docker push ${{ secrets.DOCKERHUB_USERNAME }}/zapishis-web:${{ steps.vars.outputs.web_tag }}
|
docker push ${{ secrets.DOCKERHUB_USERNAME }}/zapishis-web:${{ steps.vars.outputs.web_tag }}
|
||||||
|
|
||||||
|
# ---- Bot ----
|
||||||
- name: Build bot image
|
- name: Build bot image
|
||||||
|
if: steps.changes.outputs.bot_changed == 'true'
|
||||||
run: |
|
run: |
|
||||||
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/zapishis-bot:${{ steps.vars.outputs.bot_tag }} -f ./apps/bot/Dockerfile .
|
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/zapishis-bot:${{ steps.vars.outputs.bot_tag }} -f ./apps/bot/Dockerfile .
|
||||||
|
|
||||||
- name: Push bot image to Docker Hub
|
- name: Push bot image
|
||||||
|
if: steps.changes.outputs.bot_changed == 'true'
|
||||||
run: |
|
run: |
|
||||||
docker push ${{ secrets.DOCKERHUB_USERNAME }}/zapishis-bot:${{ steps.vars.outputs.bot_tag }}
|
docker push ${{ secrets.DOCKERHUB_USERNAME }}/zapishis-bot:${{ steps.vars.outputs.bot_tag }}
|
||||||
|
|
||||||
|
# ---- Cache Proxy ----
|
||||||
- name: Build cache-proxy image
|
- name: Build cache-proxy image
|
||||||
|
if: steps.changes.outputs.cache_proxy_changed == 'true'
|
||||||
run: |
|
run: |
|
||||||
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/zapishis-cache-proxy:${{ steps.vars.outputs.cache_proxy_tag }} -f ./apps/cache-proxy/Dockerfile .
|
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/zapishis-cache-proxy:${{ steps.vars.outputs.cache_proxy_tag }} -f ./apps/cache-proxy/Dockerfile .
|
||||||
|
|
||||||
- name: Push cache-proxy image to Docker Hub
|
- name: Push cache-proxy image
|
||||||
|
if: steps.changes.outputs.cache_proxy_changed == 'true'
|
||||||
run: |
|
run: |
|
||||||
docker push ${{ secrets.DOCKERHUB_USERNAME }}/zapishis-cache-proxy:${{ steps.vars.outputs.cache_proxy_tag }}
|
docker push ${{ secrets.DOCKERHUB_USERNAME }}/zapishis-cache-proxy:${{ steps.vars.outputs.cache_proxy_tag }}
|
||||||
|
|
||||||
@ -82,11 +115,11 @@ jobs:
|
|||||||
chmod 600 ~/.ssh/id_rsa
|
chmod 600 ~/.ssh/id_rsa
|
||||||
ssh-keyscan -p ${{ secrets.VPS_PORT }} -H ${{ secrets.VPS_HOST }} >> ~/.ssh/known_hosts
|
ssh-keyscan -p ${{ secrets.VPS_PORT }} -H ${{ secrets.VPS_HOST }} >> ~/.ssh/known_hosts
|
||||||
|
|
||||||
- name: Ensure zapishis directory exists on VPS
|
- name: Ensure zapishis directory exists
|
||||||
run: |
|
run: |
|
||||||
ssh -i ~/.ssh/id_rsa -p ${{ secrets.VPS_PORT }} -o StrictHostKeyChecking=no ${{ secrets.VPS_USER }}@${{ secrets.VPS_HOST }} "mkdir -p /home/${{ secrets.VPS_USER }}/zapishis"
|
ssh -i ~/.ssh/id_rsa -p ${{ secrets.VPS_PORT }} -o StrictHostKeyChecking=no ${{ secrets.VPS_USER }}@${{ secrets.VPS_HOST }} "mkdir -p /home/${{ secrets.VPS_USER }}/zapishis"
|
||||||
|
|
||||||
- name: Create real .env file for production
|
- name: Create .env for production
|
||||||
run: |
|
run: |
|
||||||
echo "BOT_TOKEN=${{ secrets.BOT_TOKEN }}" > .env
|
echo "BOT_TOKEN=${{ secrets.BOT_TOKEN }}" > .env
|
||||||
echo "LOGIN_GRAPHQL=${{ secrets.LOGIN_GRAPHQL }}" >> .env
|
echo "LOGIN_GRAPHQL=${{ secrets.LOGIN_GRAPHQL }}" >> .env
|
||||||
@ -105,27 +138,19 @@ jobs:
|
|||||||
echo "OFFER_URL=${{ secrets.OFFER_URL }}" >> .env
|
echo "OFFER_URL=${{ secrets.OFFER_URL }}" >> .env
|
||||||
echo "PRIVACY_URL=${{ secrets.PRIVACY_URL }}" >> .env
|
echo "PRIVACY_URL=${{ secrets.PRIVACY_URL }}" >> .env
|
||||||
|
|
||||||
- name: Copy .env to VPS via SCP
|
- name: Copy .env and docker-compose.yml to VPS
|
||||||
uses: appleboy/scp-action@master
|
uses: appleboy/scp-action@master
|
||||||
with:
|
with:
|
||||||
host: ${{ secrets.VPS_HOST }}
|
host: ${{ secrets.VPS_HOST }}
|
||||||
username: ${{ secrets.VPS_USER }}
|
username: ${{ secrets.VPS_USER }}
|
||||||
key: ${{ secrets.VPS_SSH_KEY }}
|
key: ${{ secrets.VPS_SSH_KEY }}
|
||||||
port: ${{ secrets.VPS_PORT }}
|
port: ${{ secrets.VPS_PORT }}
|
||||||
source: '.env'
|
source: |
|
||||||
|
.env
|
||||||
|
docker-compose.yml
|
||||||
target: '/home/${{ secrets.VPS_USER }}/zapishis/'
|
target: '/home/${{ secrets.VPS_USER }}/zapishis/'
|
||||||
|
|
||||||
- name: Copy docker-compose.yml to VPS via SCP
|
- name: Deploy on VPS
|
||||||
uses: appleboy/scp-action@master
|
|
||||||
with:
|
|
||||||
host: ${{ secrets.VPS_HOST }}
|
|
||||||
username: ${{ secrets.VPS_USER }}
|
|
||||||
key: ${{ secrets.VPS_SSH_KEY }}
|
|
||||||
port: ${{ secrets.VPS_PORT }}
|
|
||||||
source: 'docker-compose.yml'
|
|
||||||
target: '/home/${{ secrets.VPS_USER }}/zapishis/'
|
|
||||||
|
|
||||||
- name: Login and deploy on VPS
|
|
||||||
run: |
|
run: |
|
||||||
ssh -i ~/.ssh/id_rsa -p ${{ secrets.VPS_PORT }} -o StrictHostKeyChecking=no ${{ secrets.VPS_USER }}@${{ secrets.VPS_HOST }} "
|
ssh -i ~/.ssh/id_rsa -p ${{ secrets.VPS_PORT }} -o StrictHostKeyChecking=no ${{ secrets.VPS_USER }}@${{ secrets.VPS_HOST }} "
|
||||||
cd /home/${{ secrets.VPS_USER }}/zapishis && \
|
cd /home/${{ secrets.VPS_USER }}/zapishis && \
|
||||||
|
|||||||
@ -1,13 +1,18 @@
|
|||||||
import { seconds } from 'src/utils/time';
|
import { seconds } from 'src/utils/time';
|
||||||
|
|
||||||
export const queryTTL: Record<string, number | false> = {
|
export const queryTTL: Record<string, number | false> = {
|
||||||
Login: false,
|
|
||||||
GetCustomer: seconds().fromHours(24),
|
GetCustomer: seconds().fromHours(24),
|
||||||
|
GetCustomers: false,
|
||||||
|
GetInvited: false,
|
||||||
|
GetInvitedBy: false,
|
||||||
GetOrder: seconds().fromHours(24),
|
GetOrder: seconds().fromHours(24),
|
||||||
|
GetOrders: false,
|
||||||
GetService: seconds().fromHours(24),
|
GetService: seconds().fromHours(24),
|
||||||
|
GetServices: false,
|
||||||
GetSlot: seconds().fromHours(24),
|
GetSlot: seconds().fromHours(24),
|
||||||
|
GetSlots: false,
|
||||||
GetSlotsOrders: false,
|
GetSlotsOrders: false,
|
||||||
GetSubscriptionPrices: seconds().fromHours(24),
|
GetSubscriptionHistory: false,
|
||||||
GetSubscriptions: seconds().fromHours(24),
|
GetSubscriptions: false,
|
||||||
GetSubscriptionSettings: seconds().fromHours(1),
|
Login: false,
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user