Skip to content

Commit

Permalink
Adding GitHub Action workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
ankushgarg1998 committed Sep 9, 2024
1 parent d93c946 commit 6607381
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Execute the bot script.

run-name: ${{ github.actor }} executed the bot script.

on:
schedule:
- cron: '*/5 * * * *' # run every 5 minutes
# workflow_dispatch: # run manually

jobs:
build:
runs-on: ubuntu-latest
environment: production
steps:
- name: Checkout Codebase
uses: actions/checkout@v4 # Checkout the repository content to github runner

- name: Setup node
uses: actions/setup-node@v4
with:
node-version: '20.3.0' # install the node version needed

- name: Install npm packages
run: npm install # install the npm packages

- name: Create config.json file.
run: |
mv ./config/config-boilerplate.json ./config/config.json
- name: Execute node script # run app.js
env:
NODE_ENV: production
MONGODB_URI: ${{ secrets.MONGODB_URI }}
BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
run: node app.js

- name: Commit files
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add -A
git diff-index --quiet HEAD || (git commit -a -m "updated data")
- name: Push changes
uses: ad-m/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: master
12 changes: 12 additions & 0 deletions config/config-boilerplate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"development": {
"ENVIRONMENT": "development",
"PORT": 8080,
"MONGODB_URI": "mongodb://localhost:27017/IPURBotDev",
"BOT_TOKEN": "<TELEGRAM_BOT_TOKEN_HERE>"
},
"production": {
"ENVIRONMENT": "production",
"PORT": 8080
}
}

0 comments on commit 6607381

Please sign in to comment.