DEV Community

Cover image for My first time using Github actions
Julian Markiewicz
Julian Markiewicz

Posted on

My first time using Github actions

So Hi! Kinda awkward to write a post on Dev.to. I use tricks, tips, reading articles from this website almost every day, but I have never written a post in here (so for me this is a bit of a big deal, but from now on I will try to muster my excitement).

Github actions are something I was hoping to try sooner but there had always been an excuse. But with the announcement of actionshackaton there are no excuses to dive in and learn something new.

My Workflow

I decided to do something which is unnecessary and thus would neatly fell into category of wacky wildcards. I decided to prepare yoda translator for issue and pull request comments. In order to start using this action you have to prepare few things.

Prerequisites

  1. You have to create a secret (if you don't know what I'm talking about look here), inside your repository where you intend to use the action, with Github Access Token inside (here is Github doc about how to do it step by step). This is required in order for the action to work.
  2. Also if you want to make more than 60 API calls daily (this is 5 calls per hour), you have to create a secret with a token from funtranslations website.

How to use it

After you have added the Github Access Token as a secret you can start adding the configuration for your action within destined project. Here you can follow this doc from Github.

To summarise what needs to be done:

  • create, in the root of your project, directory called .github,
  • then within this directory add a folder called workflows,
  • inside workflows folder add main.yml file,

After all this, inside previously created file, put code which looks similar to this one (Github user name will differ so you have to change the part which uses markiewiczjulian/yoda-translation-action@master and also you could have named your secrets differently to me, so sections with properties: githubAccessToken, translationApiToken, would be your point of interest).

name: Yoda translation

on:
  pull_request_review_comment:
    types: [created, edited]
  issue_comment:
    types: [created]

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
        name: Use Node.js 12.X
      - run: npm install
      - uses: markiewiczjulian/yoda-translation-action@master
        name: use yoda-translation-action
        with:
          githubAccessToken: ${{secrets.GIT_ACCESS_TOKEN}}
          translationApiToken: ${{secrets.TRANSLATION_API_TOKEN}}
      - uses: actions/setup-node@v1
        name: use actions/setup-node
        with:
          node-version: "12.X"
        env:
          CI: true
Enter fullscreen mode Exit fullscreen mode

Remember that translationApiToken is optional and if you don't have it (you want to use a free tier on funtranslations), you simply don't include it in the yml file.

How this works

After you or your colleague submit a comment inside an issue or pull request the action gets triggered. Action will replace the message to translation from funtranslations and also add the info at the text beginning ([translated from English, to yodish]:).

Alt Text

Submission Category:

Wacky Wildcards

Yaml File or Link to Code

Here you can check out the code of yoda action.

GitHub logo markiewiczjulian / yoda-translation-action

Github action which translates the issue comments and pull request comments from english to yodish (Yoda language)

About

This is a Github action which translates the issue comments and pull request comments from english to yodish (Yoda language).

Prerequisites

You have to create an secret (if you don't know what I'm talking about look here), inside your repository where you intend to use the action, with Github Access Token inside (here is Github doc about how to do it step by step). Also if you want to make more than 60 API calls daily (this is 5 calls per hour), you have to create a secret with token from funtranslations website.

How to use it

After you have added the Github Access Token as a secret you can start adding the configuration for your action within destined project. Here you can follow this doc from Github. But to surmise what needs to be done:

  • you have to create, in the root of your project, directory…



You can also check the yoda-translation-action-test repository to see simple node.js app where I have used this action.

GitHub logo markiewiczjulian / yoda-translation-action-test

This is a simple node.js app which uses the custom action from yoda-translation-action repository

About

This is a simple node.js app which uses the custom action from a yoda-translation-action repository. For more information on how it works, see yoda-translation-action repository.

MIT License

Copyright (c) 2020 Julian Markiewicz

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.…

Top comments (0)