Skip to content

feat: docker build

feat: docker build #1

Workflow file for this run

name: Build and Deploy
on:
push:
branches:
- dev
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '20'
- name: Install dependencies
run: yarn install
- name: Ensure config file exists and populate with secrets
run: |
if [ ! -f src/config.json ]; then
cat <<EOF > src/config.json
{
"TOKEN": "${{ secrets.TOKEN }}",
"CLIENT_ID": "${{ secrets.CLIENT_ID }}"
}
EOF
else
echo "Config file already exists."
fi
- name: Build the application
run: yarn build
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build and Push Docker image
uses: docker/build-push-action@v2
with:
context: ./
file: Dockerfile
push: true
tags: dfanso/discord-bot-boilerplate:latest
build-args: |
MONGO_URI=${{ secrets.MONGO_URI }}
# deploy:
# needs: build
# runs-on: ubuntu-latest
# steps:
# - name: Install sshpass
# run: sudo apt-get install sshpass
# - name: Deploy to VPS
# env:
# VPS_PASSWORD: ${{ secrets.VPS_PASSWORD }}
# run: |
# sshpass -p $VPS_PASSWORD ssh -o StrictHostKeyChecking=no ${{ secrets.VPS_USERNAME }}@${{ secrets.VPS_IP }} '
# docker pull dfanso/ethos-bot:latest &&
# docker stop ethos-bot || true &&
# docker rm ethos-bot || true &&
# docker run -d --name ethos-bot -p 80:3000 dfanso/ethos-bot:latest'