From 8ba9b663a7a61950b04bfe65929a6efb717ffb77 Mon Sep 17 00:00:00 2001 From: fearandesire Date: Mon, 4 Nov 2024 08:30:21 -0500 Subject: [PATCH] ci: ssh into host for simplicity --- .github/workflows/docker-ci.yaml | 81 ++++++++++---------------------- Dockerfile | 2 - 2 files changed, 25 insertions(+), 58 deletions(-) diff --git a/.github/workflows/docker-ci.yaml b/.github/workflows/docker-ci.yaml index c9c0c134..b7a8dfc8 100644 --- a/.github/workflows/docker-ci.yaml +++ b/.github/workflows/docker-ci.yaml @@ -1,66 +1,35 @@ -name: "Docker CI" - -on: - push: - branches: [main] - pull_request: - branches: [main] +name: "Docker CI/CD" env: REGISTRY: ghcr.io IMAGE_NAME: pluto-betting-bot +on: + push: + branches: [main] + pull_request: + branches: [main] + jobs: - build-and-push: + deploy: runs-on: ubuntu-latest - permissions: - contents: read - packages: write - steps: - - uses: actions/checkout@v3 - - - name: Download Swagger Specification - run: | - curl -o Khronos-Swagger-Spec-v1.json ${{ secrets.SWAGGER_SPEC_URL }} - - - name: Login to GitHub Container Registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Download assets - run: | - docker pull ghcr.io/${{ github.repository_owner }}/pluto-assets:latest - docker create --name temp ghcr.io/${{ github.repository_owner }}/pluto-assets:latest - docker cp temp:/assets/. ./assets/ - docker rm temp - - - name: Log in to the Container registry - uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 - with: - images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }} + - name: Checkout Repository + uses: actions/checkout@v3 - - name: Build and push Docker image - uses: docker/build-push-action@v6.9.0 + - name: Deploy to VPS + uses: appleboy/ssh-action@master with: - context: . - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - build-args: | - DOTENV_KEY=${{ secrets.DOTENV_KEY }} - R_HOST=${{ secrets.R_HOST }} - network: | - ${{ secrets.NETWORK_1 }} - ${{ secrets.NETWORK_2 }} + host: ${{ secrets.SSH_HOST }} + username: ${{ secrets.SSH_USERNAME }} + key: ${{ secrets.SSH_KEYFILE }} + password: ${{ secrets.SSH_PASS }} + script: | + cd apps/Pluto-Betting-Bot + git pull origin main + # Download the latest Swagger spec + curl -o Khronos-Swagger-Spec-v1.json '${{ secrets.SWAGGER_SPEC_URL }}' + echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin + docker pull ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:latest + docker-compose down + docker-compose up -d \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 23a530a8..a052d8ca 100644 --- a/Dockerfile +++ b/Dockerfile @@ -56,8 +56,6 @@ RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-l ENV NODE_ENV=production ENV DOTENV_KEY=$DOTENV_KEY ENV R_HOST=$R_HOST -LABEL org.opencontainers.image.source="https://github.com/fearandesire/Pluto-Betting-Bot" -LABEL org.opencontainers.image.description="Pluto Betting Bot" EXPOSE 2090 CMD ["pnpm", "start"] \ No newline at end of file