Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Mechanolatry committed Mar 14, 2024
2 parents d2e4b4f + ba07030 commit 9e3aa04
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 70 deletions.
2 changes: 1 addition & 1 deletion .github/steps/-step.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1
2
95 changes: 26 additions & 69 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,90 +15,47 @@ _Write your own GitHub JavaScript Action and automate customized tasks unique to
</header>

<!--
<<< Author notes: Step 1 >>>
Choose 3-5 steps for your course.
The first step is always the hardest, so pick something easy!
Link to docs.github.com for further explanations.
Encourage users to open new tabs for steps!
<<< Author notes: Step 2 >>>
Start this step by acknowledging the previous step.
Define terms and link to docs.github.com.
-->

## Step 1: Initialize a new JavaScript project
## Step 2: Configure Your Action

_Welcome to the course :tada:_
_Let's keep going! :bike:_

### Configuring a workflow
### Excellent!

Actions are enabled on your repository by default, but we still have to tell our repository to use them. We do this by creating a workflow file in our repository.
Now that we have the custom action pre-requisites, let us create **joke-action** action.

A **workflow** file can be thought of as the recipe for automating a task. They house the start to finish instructions, in the form of `jobs` and `steps`, for what should happen based on specific triggers.
### :keyboard: Activity 1: Configure Your Action

Your repository can contain multiple **workflow** files that carry out a wide variety of tasks. It is important to consider this when deciding on a name for your **workflow**. The name you choose should reflect the tasks being performed.
All of the following steps take place inside of the `.github/actions/joke-action` directory.

_In our case, we will use this one **workflow** file for many things, which leads us to break this convention for teaching purposes._
We will start with using the parameters that are **required** and later implement some optional parameters as our action evolves.

Read more about [workflows](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/configuring-a-workflow#choosing-the-type-of-actions-for-your-workflow)
1. Create a new file in: `.github/actions/joke-action/action.yml`
2. Add the following contents to the `.github/actions/joke-action/action.yml` file:

## On to your development environment
```yaml
name: "my joke action"

Our JavaScript actions are going to leverage the [GitHub ToolKit](https://github.com/actions/toolkit) for developing GitHub Actions.
description: "use an external API to retrieve and display a joke"

This is an external library that we will install using `npm` which means that you will need [Node.js](https://nodejs.org/) installed.

We find writing actions to be easier from a local environment vs trying to do everything right here in the repository. Doing these steps locally allows you to use the editor of your choice so that you have all the extensions and snippets you are used to when writing code.

If you do not have a preferred environment then we suggest following along exactly as you see on the screen, which means you'll need to install [Visual Studio Code](https://code.visualstudio.com/).

## Don't forget to set up your workstation

Most of your work going forward will take place away from your Skills repository, so before continuing with the course ensure you have the following installed on your **local machine**.

1. [ ] [Node.js](https://nodejs.org)
2. [ ] [Visual Studio Code](https://code.visualstudio.com/) or your editor of choice
3. [ ] [Git](https://git-scm.com/)

### :keyboard: Activity 1: Initialize a new JavaScript project

Once you have the necessary tools installed locally, follow these steps to begin creating your first action.

1. Open the **Terminal** (Mac and Linux) or **Command Prompt** (Windows) on your local machine
2. Clone your Skills repo to your local machine:
```shell
git clone <this repository URL>.git
```
3. Navigate to the folder you just cloned:
```shell
cd <local folder with cloned repo>
runs:
using: "node16"
main: "main.js"
```
4. We are using branch called `main`.
```shell
git switch main
```
5. Create a new folder for our actions files:
```shell
mkdir -p .github/actions/joke-action
```
6. Navigate to the `joke-action` folder you just created:
```shell
cd .github/actions/joke-action
```
7. Initialize a new project:
```shell
npm init -y
```
8. Install the **request**, **request-promise** and **@actions/core** dependencies using `npm` from the [GitHub ToolKit] (https://github.com/actions/toolkit):
```shell
npm install --save request request-promise @actions/core
```
9. Commit those newly added files,we will remove the need to upload **node_modules** in a later step:
3. Save the `action.yml` file
4. Commit the changes and push them to the `main` branch:
```shell
git add .
git commit -m 'add project dependencies'
git add action.yml
git commit -m 'create action.yml'
git pull
git push
```
10. Push your changes to your repository:
```shell
git push
```
11. Wait about 20 seconds then refresh this page (the one you're following instructions from). [GitHub Actions](https://docs.github.com/en/actions) will automatically update to the next step.
5. Wait about 20 seconds then refresh this page (the one you're following instructions from). [GitHub Actions](https://docs.github.com/en/actions) will automatically update to the next step.

<footer>

Expand Down

0 comments on commit 9e3aa04

Please sign in to comment.