-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from ankushgarg1998/github-action
Adding GitHub Action workflow #8
- Loading branch information
Showing
2 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |