From f549c60fd86704f8450ee20432ea6dbe3de04a60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Henrique?= Date: Sat, 31 May 2025 10:36:08 -0300 Subject: [PATCH] kkkkkkkkkk --- .gitea/workflows/main.yaml | 64 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 .gitea/workflows/main.yaml diff --git a/.gitea/workflows/main.yaml b/.gitea/workflows/main.yaml new file mode 100644 index 0000000..0b874e7 --- /dev/null +++ b/.gitea/workflows/main.yaml @@ -0,0 +1,64 @@ +name: Frontend Build and Deploy + +on: + workflow_dispatch: {} + +env: + REGISTRY_HOST: git.ivanch.me + IMAGE_FRONTEND: ${{ env.REGISTRY_HOST }}/ivanch/opencand.ui + # ─────────────────────────────────────────────────────────────────────────── + DEPLOY_USER: ${{ secrets.LIVE_HOST }} + DEPLOY_HOST: ${{ secrets.LIVE_USERNAME }} + DEPLOY_PATH: ${{ secrets.LIVE_PROJECT_DIR }} + +jobs: + build_and_deploy: + runs-on: ubuntu-latest + + steps: + - name: Check out repository + uses: actions/checkout@v2 + + - name: Log in to Container Registry + run: | + echo "${{ secrets.REGISTRY_PASSWORD }}" \ + | docker login "${{ env.REGISTRY_HOST }}" \ + -u "${{ secrets.REGISTRY_USERNAME }}" \ + --password-stdin + + - name: Build and Push Frontend Image + run: | + TAG=latest + + docker build \ + --build-arg VITE_API_URL="http://api.opencand.ivanch.me" \ + -t "${{ env.IMAGE_FRONTEND }}:${TAG}" \ + . + + docker push "${{ env.IMAGE_FRONTEND }}:${TAG}" + + - name: Set up SSH + run: | + mkdir -p ~/.ssh + echo "${{ secrets.LIVE_KEY }}" > ~/.ssh/id_rsa + chmod 600 ~/.ssh/id_rsa + + # Add the host to known_hosts so SSH does not prompt + ssh-keyscan -H "${{ env.DEPLOY_HOST }}" >> ~/.ssh/known_hosts + + - name: Deploy to Production Server + run: | + TAG=latest + + ssh "${{ env.DEPLOY_USER }}@${{ env.DEPLOY_HOST }}" << 'EOF' + cd "${{ env.DEPLOY_PATH }}" + + # Replace the “image:” line for the frontend service + # sed -i \ + # "s|image: .*/frontend:.*|image: ${{ env.IMAGE_FRONTEND }}:${TAG}|g" \ + # docker-compose.yml + + # Pull only the new frontend image, then restart that service + docker-compose pull frontend + docker-compose up -d frontend + EOF