Skip to content

Commit

Permalink
ci: ssh into host for simplicity
Browse files Browse the repository at this point in the history
  • Loading branch information
fearandesire committed Nov 4, 2024
1 parent 9271d13 commit 8ba9b66
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 58 deletions.
81 changes: 25 additions & 56 deletions .github/workflows/docker-ci.yaml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 0 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

0 comments on commit 8ba9b66

Please sign in to comment.