DEV Community

Cover image for Marvel-ize πŸ¦Έβ€β™€οΈ your repo with Github actions
Lucia Cerchie
Lucia Cerchie

Posted on

Marvel-ize πŸ¦Έβ€β™€οΈ your repo with Github actions

For the DEV Github Actions Hackathon 2021 I wrote a workflow to Marvel-ize your repo!

My Workflow

Here's the workflow:


name: Marvel-ize
on: [pull_request]
jobs:
  giphy-generator:
    name: GIPHY Generator
    runs-on: ubuntu-latest
    steps:
      - name: GIPHY Generator
        id: giphy_generator
        uses: iamhughes/giphy-generator@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
          GIPHY_TOKEN: ${{ secrets.GIPHY_TOKEN }} # This token should be created on giphy.com: https://developers.giphy.com/dashboard/?create=true
        with:
          rating: 'g'
          lang: 'en'
  update-readme:
    name: Update Quote README
    runs-on: ubuntu-latest
    steps:
      - uses: siddharth2016/quote-readme@main
        with:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}"
Enter fullscreen mode Exit fullscreen mode

Let's break it down. The first action is the GIPHY Generator and it generate a giphy when you write /giphy keyword_here in a PR. So you can trigger gifs of Marvel characters!

Spidermen pointing at each other

Next up, we have Update Quote README, which updates your README with a Marvel quote each time an event happens. The original example uses a cron job, but I changed the logic up a bit to trigger on a PR instead of the daily time the cron job specified.

And that was it for the actions I included in my workflow!

Submission Category:

Wacky Wildcards

Yaml File or Link to Code

Pssst -- my repo that holds the workflow is here https://github.com/Cerchie/github-actions-hackathon-2021

Additional Resources / Info

What I learned:

  1. If you're editing workflow and runs, delete your old runs inside the Github user interface, as well as update your current branch! Otherwise the old workflows will run every time you start the trigger action.

  2. yaml is no joke
    The runs won't work if it isn't formatted properly, so watch out!

  3. Careful with dashes. At one point I had a - in front of my id under an if statement, and that clogged the whole thing up since the if statement is supposed to modify that step.

  4. Github secrets are by repo and by environment. The secrets that you use in actions are for the repo! Don't mix 'em up or your action might not run.

What I want to learn:

There are two ways that I found out to integrate workflows, but I couldn't get them to work in the time I had left. So I'd like to work on:

1.
jobs.if - this syntax runs the next step if a condition is satisfied.

2.
Integrating workflows with job.needs - this syntax makes two jobs interdependent on each other.

Conclusion

All in all, I had a good time, learned a few things, and learned what I want to learn in the future! And I couldn't finish this post without thanking my friend @bogdaaamn for all of his help. Check out his code of conduct action!

Top comments (2)

Collapse
 
bogdaaamn profile image
Bogdan Covrig

Amazing work @cerchie !! Happy you submitted it!

Collapse
 
cerchie profile image
Lucia Cerchie

thanks!