DEV Community

Yogi Wisesa
Yogi Wisesa

Posted on

Github Actions & Telegram Notification

This project is a telegram bot and build with node js and use telegraf as a chatbot framework.

My Workflow

Since I need to deploy the project to the VPS and using ssh, I use github actions to automate the process. The actions that I use are:

GitHub logo appleboy / ssh-action

GitHub Actions for executing remote ssh commands.


I use this action to connect to my VPS using SSH then run the deployment command.

GitHub logo appleboy / telegram-action

GitHub Action that sends a Telegram message.


After the deployment is complete, this action will notify me via telegram, I prefer to use telegram than the other messaging service.

And the repo where I use this workflow is here

The workflow

name: Deploy Ambil IG

on:
  push:
    branches: [ master ]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Deploy Ambil IG
        uses: appleboy/ssh-action@v0.1.2
        with:
          host: ${{secrets.SSH_HOST}}
          username: ${{ secrets.SSH_USERNAME }}
          password: ${{ secrets.SSH_PASSWORD }}
          script: |
            cd ~/repos/folder-name
            git pull
            npm install
            pm2 restart app-name
      - name: send custom message with args
        uses: appleboy/telegram-action@master
        with:
          to: ${{ secrets.TELEGRAM_TO }}
          token: ${{ secrets.TELEGRAM_TOKEN }}
          args: 👨🏻‍💻 User ${{github.actor}} in ${{ github.repository }} repository. Make ${{ github.event_name }}. Job ${{github.job}}.

Don't forget to add the secrets to your repository.

Submission Category:

DIY Deployments

Yaml File or Link to Code

YAML example

Additional Resources / Info

GitHub logo appleboy / ssh-action

GitHub Actions for executing remote ssh commands.

GitHub logo appleboy / telegram-action

GitHub Action that sends a Telegram message.

[Note:] # (Be sure to link to any open source projects that are using your workflow!)

Top comments (2)

Collapse
 
chuve profile image
Evgeny Chuvelev

Thanks Yogi! I used your configurations as a reference to build mine own.

Collapse
 
yogiwisesa profile image
Yogi Wisesa

Yess, sure!