Skip to content

refactor: crate folder (#423) #423

refactor: crate folder (#423)

refactor: crate folder (#423) #423

Workflow file for this run

name: Deployment AppFlowy Cloud and Admin Frontend for Kube Environment
on:
push:
branches:
- 'main'
- 'test_deploy_*'
jobs:
image_build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: build docker images
run: |
docker compose build appflowy_cloud admin_frontend
- name: push docker images to docker hub
run: |
docker tag appflowyinc/appflowy_cloud appflowyinc/appflowy_cloud:${GITHUB_SHA}
docker tag appflowyinc/admin_frontend appflowyinc/admin_frontend:${GITHUB_SHA}
echo ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | docker login --username appflowyinc --password-stdin
docker push appflowyinc/appflowy_cloud:${GITHUB_SHA}
docker push appflowyinc/admin_frontend:${GITHUB_SHA}
image_deploy:
needs: image_build
runs-on: [test-kube-worker]
steps:
- name: Checkout Deployment
uses: actions/checkout@v4
with:
repository: AppFlowy-IO/AppFlowy-Cloud-Deployment
token: ${{ secrets.GH_PAT }}
- name: apply images
run: |
# export env var
source environments/base.env
source environments/test.env
export APPFLOWY_GOTRUE_JWT_SECRET=${{ secrets.TEST_GOTRUE_JWT_SECRET }}
export APPFLOWY_GOTRUE_JWT_EXP=${{ secrets.TEST_GOTRUE_JWT_EXP }}
export APPFLOWY_S3_ACCESS_KEY=${{ secrets.TEST_APPFLOWY_S3_ACCESS_KEY }}
export APPFLOWY_S3_SECRET_KEY=${{ secrets.TEST_APPFLOWY_S3_SECRET_KEY }}
export APPFLOWY_GOTRUE_ADMIN_PASSWORD=${{ secrets.TEST_APPFLOWY_GOTRUE_ADMIN_PASSWORD }}
export ADMIN_FRONTEND_IMAGE=appflowyinc/admin_frontend:${GITHUB_SHA}
export APPFLOWY_IMAGE=appflowyinc/appflowy_cloud:${GITHUB_SHA}
# keep track of final env deployment files
mkdir deployed
# dump all env var
env > deployed/.env
# deploy appflowy cloud
envsubst < kubernetes/templates/appflowy-cloud-deployment.yaml | tee deployed/appflowy-cloud-deployment.yaml | kubectl apply -f -
envsubst < kubernetes/templates/appflowy-cloud-service.yaml | tee deployed/appflowy-cloud-service.yaml | kubectl apply -f -
# deploy admin_frontend
envsubst < kubernetes/templates/admin-frontend-deployment.yaml | tee deployed/admin-frontend-deployment.yaml | kubectl apply -f -
envsubst < kubernetes/templates/admin-frontend-service.yaml | tee deployed/admin-frontend-service.yaml | kubectl apply -f -
# wait for all pods to be ready
tried=0
while true; do
if [ $tried -eq 10 ]; then
echo "Waited too long for all pods to be ready"
exit 1
fi
non_running_pods=$(kubectl get pods --field-selector=status.phase!=Running | grep -v STATUS | wc -l)
if [ $non_running_pods -eq 0 ]; then
echo "All pods are ready."
exit 0
else
echo "Waiting for all pods to be ready ..."
kubectl get pods
tried=$((tried + 1))
sleep 5
fi
done
- name: delete built images
run: |
TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d '{"username": "appflowyinc", "password": "${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}"}' https://hub.docker.com/v2/users/login/ | jq -r .token)
curl -s -X DELETE -H "Authorization: JWT ${TOKEN}" https://hub.docker.com/v2/repositories/appflowyinc/appflowy_cloud/tags/${GITHUB_SHA}/
curl -s -X DELETE -H "Authorization: JWT ${TOKEN}" https://hub.docker.com/v2/repositories/appflowyinc/admin_frontend/tags/${GITHUB_SHA}/