2
NitinSahu
123d

How can I make a bot which makes a single commit everyday at a specific time for a particular repository?
The commit can be anything like insertion in readme or creating a new file.

I tried to accomplish this using python selenium I deployed it on heroku, the problem I am facing is github doesn't allows to crawl on it so it sends a verification code to me on mail and all my further selenium actions fail due it this.☹️

Comments
  • 4
    Python
    Edit file with a newline
    Git commit to console/terminal
    Git push

    Seriously, crawling web is over complicated for something so minimal.
  • 0
    @C0D4 how can I deploy this on heroku or how will the git command get executed when I upload it to heroku
  • 1
    @NitinSahu schedule a cron in Heroku and execute your python script

    https://devcenter.heroku.com/articl...

    From there, you should use shell commands to make your git commits using os.system(commandToRun)
    I think heroku allows shell access for this (been a while since I used it)

    Then yea not so complicated after that part.
  • 2
    EASY. Write a commit script:

    cd $REPO
    git commit -a -m "automatic commit"
    git push

    and set up a cron job that executes that script.
  • 2
    But why
  • 1
    @acz0903 seconding the cron idea, it's what I would've recommended too. Surprised no one said it before you tbh.
  • 1
    Create a repo with 3 files
    1) app.py
    2) data.txt
    3) run.sh

    Now app.py should read the contents of data.txt and just replace it with a random char from [a-z] (excluding the one currently in data.txt). This way you don't get arbituary big files...

    The run.sh basically calls app.py, followed by `git add data.txt`, `git commit -m "I just want recruiterts to think, I work/commit something every day..."`, `git push origin master`

    To start every thing, clone the repo using SSH (and make sure to use private/public key auth). Next add a cronjob to run it daily.
  • 1
    @Wack your commit message is awesome 😂😂
  • 0
    @NitinSahu isn't that the usecase for this project? :P
  • 0
    @Wack Thanks a lot your help was very detailed, can you please mention where do I deploy the cronjob?
  • 1
    Cron Jobs are cronologically run commands.

    I don't use heroku, so I'm not Quote sure how it works there, as I don't think you'll get access to proper cronjobs. Usually you'll just call `crontab -e` to open the crontab (you can read more about them here: https://digitalocean.com/community/...)

    No for heroku, either go with @C0D4 proposed solution, or try this: https://devcenter.heroku.com/articl...
  • 0
    @Wack thanks a lot
    @C0D4 thanks a lot
  • 0
    @C0D4

    I did the following
    app.py - adds some characters to data.txt
    run.sh - executes app.py, git add ., git commit, git push
    main.py - scheduled a cron job which will execute run.sh

    Am I correct? Because I feel how will the changes be pushed when I have not mentioned the github repo or my credentials.
  • 0
    @C0D4 As expected got an error
  • 3
    @electrineer exactly. Oh dear God why does OP want to waste brain cells to inflate a vanity metric?

    Also why are we the only ones asking why? The rest are actually actively helping to push this -_-
  • 0
    @codebanana I see you have a problem with others helping me, I am just exploring whatever I get to learn.
  • 0
    @codebanana let hin play, if it boosts his ego :P
  • 1
    @NitinSahu either use ssh for git (with a key)

    otherwise you'll need to store the username and password on heroku (YOU SHOULDN'T DO THIS!!!)

    Oh and if you just append data to the file, no need for Python, just echo it in append mode in the run.sh script. However each Day this file will grow... And github has a filesize limit (although that's pretty big)

    Another idea would be to just write the current unix ts to the data.txt file, that would guarante unique data between commits and wouldn't require any python
  • 0
    Jenkins
  • 3
    @NitinSahu I don't have problems with you wanting to learn anything. Nor do I have problems with people helping you. It's actually great that you're willing to learn, and so many people want to help you.

    What's not-so-great imo, is that you're using all that knowledge to do something "fake".

    Why? There's more than enough bs in the tech scene already. Rise above it, be better, DO BETTER. That's how we should all differentiate ourselves instead of participating in meaningless vanity.
  • 0
    @codebanana I understand your concern totally, actually the idea of creating this bot amazed me so I wanted badly to develop it, no other intention. I am sorry if I was rude to you.
  • 0
    @codebanana I bet you a beer, that he has a YouTube channel, where he'll show off what a "good" developer he is ^^
  • 1
    @Wack Was it a compliment or a sarcastic taunt? 🤔🤔
    Anyways idgaf, you helped me thanks for that
  • 0
    @C0D4 hi, I did as you said, I have a doubt do I need to mention the commands as follows:
    git init .
    git remote add origin
    git add .
    Etc

    Or just
    git add .
    git commit
    git push

    Also what about my credentials I searched about SSH key and used but I think that it registers a remote device's ip correct me if I am wrong.
    Thank you.
  • 1
    @NitinSahu just try it. Maybe not at heroku. Just try it in your own machine! If you use Windows, you could use WSL, otherwise just use your regular terminal.

    Try first to set up your project. Then ein your script multiple times (to simulate different days).

    A better way would be to use a Docker Container for it. Start with a default Ubuntu one and connect to it's shell. Once your project works there, try to get it to work using your own Dockerfile.
  • 0
    @Wack sure! Thanks, I'll let you know if it works.
Add Comment