Skip to content

Commit

Permalink
Adding twitter deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
p-shubh committed May 23, 2024
1 parent 0da0e81 commit 8b43009
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion .github/workflows/deploy-dev.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@

name: "Build and Push to GHCR"

on:
push:
branches:
- main
- twitter_bot
- telegram_bot

jobs:
Deploy:
Expand Down Expand Up @@ -45,6 +47,19 @@ jobs:
echo "Pushing Image to GitHub Container Registry"
docker push $GITHUB_REF_IMAGE
docker push $GITHUB_BRANCH_IMAGE
- name: Build and Push Telegram Bot Docker Image
if: github.ref == 'refs/heads/telegram_bot'
run: |
export REPO_NAME=$(echo $GITHUB_REPOSITORY | tr '[:upper:]' '[:lower:]')
export CURRENT_BRANCH=${GITHUB_REF#refs/heads/}
export TAG=$([[ $CURRENT_BRANCH == $(basename ${{ github.ref }}) ]] && echo $CURRENT_BRANCH || echo "latest")
export GITHUB_REF_IMAGE=ghcr.io/$REPO_NAME:$GITHUB_SHA
export GITHUB_BRANCH_IMAGE=ghcr.io/$REPO_NAME:$TAG
docker build -t $GITHUB_REF_IMAGE -t $GITHUB_BRANCH_IMAGE .
echo "Pushing Image to GitHub Container Registry"
docker push $GITHUB_REF_IMAGE
docker push $GITHUB_BRANCH_IMAGE
- name: Deploy Docker on DEV server
if: github.ref == 'refs/heads/main'
Expand Down Expand Up @@ -76,4 +91,20 @@ jobs:
sudo docker stop netsepio-twitter-bot && sudo docker rm netsepio-twitter-bot && sudo docker image rm ghcr.io/netsepio/netsepio-discord-bot:twitter_bot
echo ${{ secrets.GHCR_TOKEN }} | sudo docker login ghcr.io -u ${{ secrets.GHCR_USERNAME }} --password-stdin
sudo docker pull ghcr.io/netsepio/netsepio-discord-bot:twitter_bot
sudo docker run --name="netsepio-twitter-bot" --env-file=.env -p 9079:8080 --net=bridge -d ghcr.io/netsepio/netsepio-discord-bot:twitter_bot
sudo docker run --name="netsepio-twitter-bot" --env-file=.env -p 9080:8080 --net=bridge -d ghcr.io/netsepio/netsepio-discord-bot:twitter_bot
- name: Deploy Docker on Telegram Bot DEV server
if: github.ref == 'refs/heads/telegram_bot'
uses: appleboy/ssh-action@v0.1.7
with:
host: ${{ secrets.DEV_REMOTE_SERVER_ADDRESS }}
username: ${{ secrets.DEV_SERVER_USERNAME }}
key: ${{ secrets.DEV_REMOTE_SERVER_KEY }}
port: ${{ secrets.DEV_SSH_PORT }}
script: |
pwd
cd telegram_bot
sudo docker stop netsepio-telegram-bot && sudo docker rm netsepio-telegram-bot && sudo docker image rm ghcr.io/netsepio/netsepio-discord-bot:telegram_bot
echo ${{ secrets.GHCR_TOKEN }} | sudo docker login ghcr.io -u ${{ secrets.GHCR_USERNAME }} --password-stdin
sudo docker pull ghcr.io/netsepio/netsepio-discord-bot:telegram_bot
sudo docker run --name="netsepio-telegram-bot" --env-file=.env -p 9081:8080 --net=bridge -d ghcr.io/netsepio/netsepio-discord-bot:telegram_bot

0 comments on commit 8b43009

Please sign in to comment.