Medium Writeups #10463
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
name: Medium Writeups | |
on: | |
schedule: | |
- cron: '*/10 * * * *' | |
push: | |
branches: | |
- main | |
# Actions project permission | |
permissions: | |
contents: write | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.20' # Specify the version of Go you want to use | |
- name: Scraping Medium Writeups | |
run: | | |
go run main.go | tee NEW-README.md | |
- name: Deleting old README.md and rename NEW-README.md | |
run: | | |
rm -rf README.md | mv NEW-README.md README.md | |
#- name: Generating MINIMAL-INFO-README.md | |
#run: | | |
# New Writeups: | |
#sed -i '/## New Writeups:/q' MINIMAL-INFO-README.md | |
#sed -i "/## New Writeups:/a $(cat README.md | grep -a "| Yes | Yes |" | cut -d"|" -f1-3 | sed 's/|/-/g' | sed 's/[&/\]/\\&/g' | tr '\n' '\0' | sed 's/\x0/\\n/g')" MINIMAL-INFO-README.md | |
# Today Writeups: | |
#echo -e "## Today Writeups:" >> MINIMAL-INFO-README.md | |
#sed -i "/## Today Writeups:/a $(cat README.md | grep -a "| Yes |$" | cut -d"|" -f1-3 | sed 's/|/-/g' | sed 's/[&/\]/\\&/g' | tr '\n' '\0' | sed 's/\x0/\\n/g')" MINIMAL-INFO-README.md | |
- name: Commit and push changes if there are any | |
run: | | |
git config --global user.name 'GitHub Actions' | |
git config --global user.email 'actions@users.noreply.github.com' | |
git add . | |
# Check if there are changes before committing | |
if ! git diff --cached --exit-code; then | |
IST_DATE=$(TZ='Asia/Kolkata' date +'%a %b %d %H:%M:%S IST %Y') | |
git commit -m "Updated List: $IST_DATE" | |
git push | |
else | |
echo "No changes to commit" | |
fi |