A Brief on GitHub Actions

##  GitHub Actions?

### The Long Story
[Here](https://help.github.com/en/actions/automating-your-workflow-with-github-actions)

### TL;DR

GitHub Actions is a toolkit that aids in the customization of a software development life cycle. In some cases, it will be rather simple to think of GitHub Actions as a continuous integration/continuous delivery(deployment) (CI/CD) service equivalent hosted by GitHub itself. A short example of GitHub Actions's application would be automating email notifications whenever a merge/pull/whatever request is made.

## Jargons

### Runners

Runners are preferably Docker containers of which GitHub Actions run on. The context of this article would primarily be restricted to GitHub-hosted runners; however, please be aware that self-hosted runners are always an option and might come in handy when highly-customized workflow is needed.

### Events
Events are workflow triggers. Events can be tweaked to listen to a specific activity, say, specified branch merges.

### Jobs
Each defined job will run on a separate GitHub-hosted runner. Jobs can run parallelly, sequentially, and/or even conditionally. 

### Steps 
Steps are building blocks of a job and run sequentially without any specifications. Steps that are defined in the same job share the same runner. They can be called to execute commands or use actions that have been created by one or another.

## A "Hello World" for GitHub Action (Explanations will come)

- Create a directory named ```.github/workflows/``` on the same level as your ```.git``` folder.
- Create a YAML[(Your Yaml Guide) ](https://www.codeproject.com/Articles/1214409/Learn-YAML-in-five-minutes) configuration file ```./github/workflows/{YOUR_WORKFLOW_NAME}.yml``` that resembles the following.

    -![bc33a63b-e6db-4505-a18e-43d8fba2d550.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/503314/851d0e7c-a168-b531-74ea-77d5d3472351.png)



- Push it along with your repository.
- GitHub would automatically scan all ```.yml``` and ```.yaml``` files contained within the previously mentioned directory and instantiate runners to hold the workflows configured by the YAML files.

## But What Exactly Is Going on?
- The above configuration file defines a task named 'test' that will be triggered whenever a push occurs on the branch master. When the task is triggered, GitHub Actions instantiates a job-running host on its server running the latest version of ubuntu. This host executes two steps, a pre-made action that sets up the python environment for that host and a self-defined `hello world` action that runs solely on command line.

- [Here's a link to the referenced material](https://github.com/andy971022/GitHub-Actions-Tutorial)

![Screenshot from 2020-03-09 07-11-01.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/503314/94cfe60b-03eb-f8c1-bb1f-7b9973ea4a0c.png)

- Go to `Actions` to see the details.

![Screenshot from 2020-03-09 07-11-36.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/503314/19e3fa67-a9cd-23e0-2407-c094819027f6.png)


- Go to `test` to see more details

![Screenshot from 2020-03-09 07-14-34.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/503314/4a3a9a42-2bc7-c621-3dbe-155a280c1cae.png)


- You now can see the statuses of your jobs and the steps within it. This is where you should be looking up primarily for troubleshooting.

## Tweaking to Your Heart's Extent
- GitHub Actions can do many more. 
- You can configure a workflow that triggers on push, pull requests, create, delete, and the list goes on. [Check this for more details on event listeners.](https://help.github.com/en/actions/reference/events-that-trigger-workflows)
- You can run your host on Ubuntu, Windows, or even MacOS. Note that the pricing may differ, especially for MacOS, which usually is ten times the pricing of setting up a Linux environment. [Pricing Details](https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners)
- You can use actions made by someone else. They're all in the GitHub Actions Market, [here.](https://github.com/marketplace?type=actions) Their usage might differ, so it's recommended that you read their documentations beforehand.