DEV Community

spiritupbro
spiritupbro

Posted on • Edited on

Pick Random Item From Dev.to Shop Based On How Much Money You Got

github action hackathon is hackathon created by dev.to i won as a runner up here as spiritbro1

My Workflow

So background of the story is, i recently participated in dev.to hackathon called web monetization hackathon and i didn't win so 😢, but thank God dev.to give us another exciting hackathon that i recently learn also by making a covid telegram notification using github action you can check that out here

and most importantly is dev.to generous enough to gave me some credit to spend on dev.to shop Thank You Dev.to Team!! 😃 but the problem is i dont know which item i want to get from dev.to shop so why dont we make a github action that can get us some random item from dev.to shop. So let's begin.

So since dev.to doesnt have api to get the item and the price tag i need to scrape the dev.to shop and save it to csv i use csv coz it is much faster than setting up a whole new database you can take a look the code here:

last scraped in 17-9-2020


List of item scraped from devto shop

no image url title price
1 https://shop.dev.to/collections/codeland/products/mug-with-color-inside-1 CodeLand Mug $ 14.0
2 https://shop.dev.to/collections/codeland/products/codeland-tote-bag CodeLand Tote bag $ 23.0
3 https://shop.dev.to/collections/codeland/products/codeland-magic-mug CodeLand Magic Mug $ 14.0
4 https://shop.dev.to/collections/codeland/products/codeland-fanny-pack-1 CodeLand Fanny Pack $ 35.0
5 https://shop.dev.to/collections/codeland/products/codeland-flip-flops CodeLand Flip-Flops $ 18.0
6 https://shop.dev.to/collections/2018-new-merch/products/embroidered-dev-champion-bomber-jacket Embroidered DEV Champion Bomber Jacket $ 65.0
7 https://shop.dev.to/collections/2018-new-merch/products/embroidered-champion-backpack Embroidered DEV Backpack $ 50.0
8 https://shop.dev.to/collections/2018-new-merch/products/dev-unisex-t-shirt DEV Tee Unisex (Multiple Colors) $ 18.0
9 https://shop.dev.to/collections/2018-new-merch/products/dev-hat DEV Hat (Multiple Colors) $ 27.0
10 https://shop.dev.to/collections/2018-new-merch/products/unisex-sweatshirt May The Source Be Open Sweatshirt $ 42.0
11 https://shop.dev.to/collections/2018-new-merch/products/black-dev-beanie Black DEV Beanie $ 19.0
12 https://shop.dev.to/collections/2018-new-merch/products/javascript-dev-unisex JavaScript DEV Unisex $ 18.0
13 https://shop.dev.to/collections/2018-new-merch/products/vintage-dev-hat-1 Vintage DEV Hat $ 27.0
14 https://shop.dev.to/collections/2018-new-merch/products/sticker-pack-1 Sticker Pack $ 12.0
15 https://shop.dev.to/collections/2018-new-merch/products/gift-card Gift Card $ 10.0
16 https://shop.dev.to/collections/2018-new-merch/products/pom-pom-knit-dev-cap Pom Pom DEV Hat (Multiple Colors) $ 19.0
17 https://shop.dev.to/collections/2018-new-merch/products/out-of-this-world-dev-t-shirt-unisex Space DEV Tee Unisex (Multiple Colors) $ 27.0
18 https://shop.dev.to/collections/2018-new-merch/products/sweatshirt DEV Crewneck Unisex
…

so what this does is, it scrape all item in dev.to shop and the price tag and put it to the csv in github repo there, so i create a python app to scrape all the item in dev.to and after that we get the raw csv from that python app then we create a github action that can randomly generate markdown with the item that randomly generated from dev.to shop for us, this github action will create a new file called DEVTOSHOP.md so it is basically can work with any repo if you just want to play with it. And doesn't disrupt an already created README.md.

Step by Step how to use this github action

  1. create a repo

  2. create a yaml file example here

  3. let it run until finished like this

s

  1. after that you get a new branch called "devto-shop-random-generator" compare that branch and pull request

s

click "create pull request"

s

then click "merge pull request"

s

then click "confirm merge"

s

you will get a new markdown file called "DEVTOSHOP.md" click that

s

and then VOILA!! you will get your random item like this that you can buy based on your budget

s

take a note that this budget is not included with shipping payment coz it will vary based on your country

Submission Category:

Wacky Wildcards

Yaml File or Link to Code

GitHub logo spiritbroski / devtoshop-random-generator

runner up dev.to hackathon https://dev.to/devteam/github-actions-hackathon-winners-announced-38o2

RANDOM DEV.TO SHOP ITEM GENERATOR

this action get you a random item that you can buy on a budget from dev.to shop

You can see the explanation here

https://dev.to/spiritbro1/pick-random-item-from-dev-to-shop-based-on-how-much-money-you-got-29a

Required argument

  • budget your budget in us dollar
  • personal_token to create a branch and pull request
  • github_repo your repo name

Example Yaml

# This is a basic workflow to help you get started with Actions
name: Get Random Item from dev.to

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
  push:
    branches: [ master ]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # This workflow contains a single job called "build"
  build:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest

    #
…
Enter fullscreen mode Exit fullscreen mode

Additional Resources / Info

Example repo that use this github action


Top comments (1)

Collapse
 
spiritupbro profile image
spiritupbro

(commentspiritbro1english) github action hackathon is hackathon created by dev.to i won as a runner up here by creating a github action that can get you random item from dev.to/shop based on your budget