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!
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:
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.
yaml is no joke
The runs won't work if it isn't formatted properly, so watch out!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.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
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/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.