Skip to content

Instantly share code, notes, and snippets.

@webprice
Created February 17, 2022 14:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save webprice/faeffaae5d7d01747a3cd6a12171d60c to your computer and use it in GitHub Desktop.
Save webprice/faeffaae5d7d01747a3cd6a12171d60c to your computer and use it in GitHub Desktop.
the github repository here https://github.com/webprice/9autocommit
import time
import random
import string
#generate random number, that will declare how many letters
#will be added to the text.txt file. Each time we change the text.txt file
#we can made a commit and push it to the reote repo
#which will be considered as a github contribution
x = random.randrange(10)
random_letter = random.choices(string.ascii_letters,k=x)
#function which actually adding those letters t the text.txt file
def random_letter_write(letters):
try:
streng = ""
for l in letters:
streng += l
time.sleep(1)
#opening the text.txt file, but if it doesn't exist, it will be created,
#this is why were using a+ attribute
with open("text.txt",'a+') as f:
f.write(streng)
time.sleep(1)
f.close()
return "all went good"
except:
return "all bad"
random_letter_write(random_letter)
#! /bin/sh
#running the python script first
#it will generate letters, add those letters to the file text.txt
#file gonna change and git will see those changes
python3 rand_gen.py
#executing classic git commands
#and since we have added and bind ssh key to the VPS system
#we can automatically upload git changes to the remote repo
#without any logins or passwords
git add .
git commit -m "autogenerated by script"
git push --force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment