diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml new file mode 100644 index 0000000..bae3f58 --- /dev/null +++ b/.gitea/workflows/deploy.yml @@ -0,0 +1,76 @@ +name: ALVA Deploy + +on: + push: + branches: [main, master] + tags: ['v*'] + pull_request: + branches: [main, master] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: eu-north-1 + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v2 + + - name: Build and push webb image + working-directory: felsokning/app + run: | + # Kopiera gemensam-moduler + mkdir -p services + cp -r ../services/gemensam services/ + + # Bygg image + docker build \ + --build-arg VITE_SUPABASE_URL="${{ secrets.VITE_SUPABASE_URL }}" \ + --build-arg VITE_SUPABASE_PUBLISHABLE_KEY="${{ secrets.VITE_SUPABASE_PUBLISHABLE_KEY }}" \ + --build-arg VITE_AI_ORKESTER_URL="https://ai.alva.landvex.com" \ + --build-arg VITE_PLATTFORM_URL="https://api.alva.landvex.com" \ + -t ${{ steps.login-ecr.outputs.registry }}/alva-webb:${{ github.sha }} \ + -t ${{ steps.login-ecr.outputs.registry }}/alva-webb:latest \ + . + + docker push ${{ steps.login-ecr.outputs.registry }}/alva-webb:${{ github.sha }} + docker push ${{ steps.login-ecr.outputs.registry }}/alva-webb:latest + + deploy: + needs: build + runs-on: ubuntu-latest + if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') + steps: + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: eu-north-1 + + - name: Update kubeconfig + run: aws eks update-kubeconfig --name landvex-prod --region eu-north-1 + + - name: Deploy to EKS + run: | + kubectl set image deployment/alva-webb \ + webb=${{ steps.login-ecr.outputs.registry }}/alva-webb:${{ github.sha }} \ + -n alva + + kubectl rollout status deployment/alva-webb -n alva --timeout=300s + + - name: Verify deployment + run: | + kubectl get pods -n alva + curl -s https://alva.landvex.com/ | grep -E "