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


This content originally appeared on DEV Community and was authored by Lucia Cerchie

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 }}"

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 use a PR.

I had fun doing this hackathon since it's my first real experience with Github actions. Here are a few things I've learned and a few things I've yet to learn.

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!


This content originally appeared on DEV Community and was authored by Lucia Cerchie


Print Share Comment Cite Upload Translate Updates
APA

Lucia Cerchie | Sciencx (2021-12-07T01:37:48+00:00) Marvel-ize your repo with Github actions. Retrieved from https://www.scien.cx/2021/12/07/marvel-ize-your-repo-with-github-actions/

MLA
" » Marvel-ize your repo with Github actions." Lucia Cerchie | Sciencx - Tuesday December 7, 2021, https://www.scien.cx/2021/12/07/marvel-ize-your-repo-with-github-actions/
HARVARD
Lucia Cerchie | Sciencx Tuesday December 7, 2021 » Marvel-ize your repo with Github actions., viewed ,<https://www.scien.cx/2021/12/07/marvel-ize-your-repo-with-github-actions/>
VANCOUVER
Lucia Cerchie | Sciencx - » Marvel-ize your repo with Github actions. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/12/07/marvel-ize-your-repo-with-github-actions/
CHICAGO
" » Marvel-ize your repo with Github actions." Lucia Cerchie | Sciencx - Accessed . https://www.scien.cx/2021/12/07/marvel-ize-your-repo-with-github-actions/
IEEE
" » Marvel-ize your repo with Github actions." Lucia Cerchie | Sciencx [Online]. Available: https://www.scien.cx/2021/12/07/marvel-ize-your-repo-with-github-actions/. [Accessed: ]
rf:citation
» Marvel-ize your repo with Github actions | Lucia Cerchie | Sciencx | https://www.scien.cx/2021/12/07/marvel-ize-your-repo-with-github-actions/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.