Skip to content

Commit

Permalink
🤖 Discord bot should be alive from prod
Browse files Browse the repository at this point in the history
  • Loading branch information
jmsalcido committed Dec 14, 2023
1 parent 621e2dc commit 69a61ea
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 3 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: 'Build & Deployment'

on:
push:
branches: [ main ]

jobs:
build:
runs-on: ubuntu-latest
environment:
name: ${{ github.ref_name }}

steps:
# Checkout the repo
- uses: actions/checkout@v2

# Setup Docker Buildx
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

# Build and push Docker Image
- name: Login to Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Preset Image Name
run: echo "IMAGE_URL=$(echo ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:$(echo ${{ github.sha }} | cut -c1-7) | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV

- name: Build and push Docker Image
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ env.IMAGE_URL }}
build-args: |
DOPPLER_TOKEN=${{ secrets.DOPPLER_TOKEN }}
# Deploy to CapRover
- name: Deploy Image to CapRover
uses: caprover/[email protected]
with:
server: "${{ vars.CAPROVER_SERVER }}"
app: "${{ vars.APP_NAME }}"
token: "${{ secrets.CAPROVER_APP_TOKEN }}"
image: ${{ env.IMAGE_URL }}

- name: send telegram message
uses: appleboy/telegram-action@master
if: always()
with:
to: ${{ secrets.TELEGRAM_GROUP_CHAT_ID }}
token: ${{ secrets.TELEGRAM_TOKEN }}
message: |
💸🤖 *[PROD Dólar en bancos bots]*
🧾 *Status: ${{ job.status }}*
#️⃣ Run # ${{github.run_number}}. Event type: *${{ github.event_name }}*
🤡 Developer: *${{github.actor}}*
🔗 Href: https://github.com/${{github.repository}}
✨ See changes: https://github.com/${{ github.repository }}/commit/${{github.sha}}
format: markdown
disable_web_page_preview: "True"
14 changes: 11 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
# Use an official Node.js runtime as the base image
FROM node:20.10-alpine

ARG DOPPLER_TOKEN
ENV DOPPLER_TOKEN=$DOPPLER_TOKEN

# Set the working directory in the container to /app
WORKDIR /app

# Update and install dependencies
# Add Doppler's RSA key
RUN wget -q -t3 'https://packages.doppler.com/public/cli/rsa.8004D9FF50437357.key' -O /etc/apk/keys/[email protected]

# Install Doppler CLI
RUN apk add --no-cache curl && \
curl -Ls https://cli.doppler.com/install.sh | sh
# Add Doppler's apk repo
RUN echo 'https://packages.doppler.com/public/cli/alpine/any-version/main' | tee -a /etc/apk/repositories
RUN apk update && apk add --no-cache libffi-dev openssl-dev build-base curl doppler

# Copy package.json and package-lock.json to the working directory
COPY package*.json ./
Expand All @@ -21,4 +29,4 @@ COPY . .
EXPOSE 3000

# Define the command to run the application
CMD ["doppler", "run", "--", "npm", "start"]
CMD ["doppler", "run", "--", "npm", "start"]

0 comments on commit 69a61ea

Please sign in to comment.