Marvel-ize 🦸‍♀️ your repo with Github actions
Tags: actionshackathon21, productivity, github, wackywildcard
Published: 2021-12-07 01:37:48


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](https://github.com/marketplace/actions/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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qm0vu934rxf6k1fyge70.png)

Next up, we have [Update Quote README](https://github.com/siddharth2016/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](https://docs.github.com/en/actions/security-guides/encrypted-secrets)! 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](https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idif) runs the next step if a condition is satisfied. 

2.
Integrating workflows with `job.needs` - [this syntax](https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idneeds) 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](https://github.com/marketplace/actions/code-of-conduct-notifier)!