Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UPDATE: Create and Publish Custom GitHub Actions #45

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ metadata:
ms.date: 04/14/2021
ms.topic: interactive-tutorial
ms.prod: learning-azure
durationInMinutes: 6
durationInMinutes: the page takes about 6 minutes, the exercise is 6 steps long and takes about 1 to 2 hours to be completed
content: |
[!include[](includes/exercise-create-custom-action.md)]
[!include[](includes/exercise-create-custom-action.md)]
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
GitHub Actions is a powerful feature that empowers you to go from code to cloud all from the comfort and convenience of your own repository. Here, you'll learn about the different types of GitHub actions and the metadata, syntax, and workflow commands to create custom GitHub actions.
Here, you'll learn about the different types of GitHub actions and the metadata, syntax, and workflow commands to create custom GitHub actions. GitHub Actions is a powerful feature that empowers you to go from code to cloud all from the comfort and convenience of your own repository.

## Types of GitHub actions

Expand Down Expand Up @@ -187,3 +187,4 @@ This text spans%0Aacross multiple lines

In addition to workflow commands, you can set exit codes to set the status of an action. This is important because when you're working with jobs in a workflow, a failed exit code will halt all concurrent actions and cancel any future actions. If you are creating a JavaScript action, you can use the actions toolkit `@actions/core` package to log a message and set a failure exit code. If you are creating a Docker container action, you can set a failure exit code in your `entrypoint.sh` script.

Next up, learn about choosing the right visibility for your action, best practices for documenting and versioning your action, and how to publish your action to the GitHub Marketplace.
23 changes: 12 additions & 11 deletions github/create-custom-github-actions/includes/introduction.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
GitHub Actions allow you to create individual, custom actions by writing code that interacts with your repository in any way you'd like, including integrating with GitHub's APIs and any publicly available third-party API. For example, an action can publish npm modules, send SMS alerts when urgent issues are created, or deploy production-ready code.
GitHub Actions allow you to create individual, custom actions by writing code that interacts with your repository in any way you'd like, including integrating with GitHub's APIs and any publicly available third-party API.

You can write your own custom actions to use in your workflow or share the actions you build with the GitHub community. To share actions you've built with the community, your repository must be public. Actions can run directly on compute resources, such as virtual machines, or in Docker containers. You can also define an action's inputs, outputs, and environment variables.
Suppose you are a developer needing your actions to run in a specific environment configuration, need custom solutions for npm modules, or deploying production-ready code. By utilizing GitHub Actions, you can write your own custom actions to use in your workflow or share the actions you build with the GitHub community. GitHub Actions can run directly on computer resources, such as virtual machines, in Docker containers, or by utilizing Node.js. You can go beyond just DevOps when you use GitHub Actions to run workflows when other events happen in your repository. And for example, you can run a workflow to automatically add the appropriate labels whenever someone creates a new issue in your repository.

In this module, you learn the different ways to create a custom action, its necessary metadata and syntax, and how to publish a custom action to the GitHub Marketplace.
In this module, you'll learn the different ways to create a custom action, its necessary metadata and syntax, and how to publish a custom action to the GitHub Marketplace.

## Learning objectives
### Learning objectives

In this module, you will:
In this module, you will learn how to:

- Identify the metadata and syntax needed to create custom GitHub actions
- Learn best practices to publish a private or public GitHub action
- Consume actions within a workflow file
- Create custom JavaScript based actions
- Publish a newly created action to the GitHub Marketplace
- Create custom JavaScript based actions

## Prerequisites
### Prerequisites

This module assumes you have basic familiarity with GitHub Actions and workflows.

- A GitHub account
- The ability to navigate and edit files in GitHub
- For more information about GitHub, see [Introduction to GitHub](https://lab.github.com/githubtraining/introduction-to-github?azure-portal=true).
- For more information about GitHub, see [Introduction to GitHub](https://learn.microsoft.com/en-us/training/modules/introduction-to-github/).
- Basic familiarity with GitHub Actions and workflows
- If you aren't familiar with workflows, jobs and steps, check out the [Automate development tasks by using GitHub Actions](/learn/modules/github-actions-automate-tasks/) module.
- If you aren't familiar with workflows, jobs and steps, check out the [Automate development tasks by using GitHub Actions](https://learn.microsoft.com/en-us/training/modules/github-actions-automate-tasks/) module.
- Basic familiarity with continuous integration using GitHub Actions and workflows
- If you're unfamiliar with continuous integration using GitHub Actions and workflows, check out [Build continuous integration workflows by using GitHub Actions](/learn/modules/github-actions-ci/)
- If you're unfamiliar with continuous integration using GitHub Actions and workflows, check out [Build continuous integration workflows by using GitHub Actions](https://learn.microsoft.com/en-us/training/modules/github-actions-ci/)

Up next, learn about the metadata, syntax, and workflow commands to create custom GitHub Actions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,6 @@ Below are the requirements to publish an action to the GitHub Marketplace. They
- The `name` cannot match an existing GitHub Marketplace category.
- The `name` cannot match an existing GitHub feature.

You can add the action you've created to the GitHub Marketplace by tagging it as a new release and then publishing it. There are a few guided steps in GitHub that enable you to publish a release of your action. More information on these steps can be found in the summary section at the end of this module.
You can add the action you've created to the GitHub Marketplace by tagging it as a new release and then publishing it. There are a few guided steps in GitHub that enable you to publish a release of your action.

Next up, an exercise walking you through writing your own GitHub JavaScript Action and automate customized tasks unique to your workflow.
10 changes: 6 additions & 4 deletions github/create-custom-github-actions/index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ uid: learn.github.create-custom-github-actions
metadata:
title: Create and publish custom GitHub actions
description: Learn how to create and publish custom GitHub actions.
ms.date: 08/08/2022
ms.date: 09/28/2022
author: a-a-ron
ms.author: aastewar
ms.topic: interactive-tutorial
Expand All @@ -14,9 +14,8 @@ abstract: |
In this module, you will learn how to:
- Identify the metadata and syntax needed to create custom GitHub actions
- Learn best practices to publish a private or public GitHub action
- Consume actions within a workflow file
- Create custom JavaScript based actions
- Publish a newly created action to the GitHub Marketplace
- Create custom JavaScript based actions
levels:
- intermediate
roles:
Expand All @@ -29,10 +28,13 @@ products:
prerequisites: |
- A GitHub account
- The ability to navigate and edit files in GitHub
- For more information about GitHub, see [Introduction to GitHub](https://lab.github.com/githubtraining/introduction-to-github?azure-portal=true).
- Basic familiarity with GitHub Actions and workflows
- If you aren't familiar with workflows, jobs and steps, check out the [Automate development tasks by using GitHub Actions](/learn/modules/github-actions-automate-tasks/) module.
- Basic familiarity with continuous integration using GitHub Actions and workflows
subjects:
- devops
- If you're unfamiliar with continuous integration using GitHub Actions and workflows, check out [Build continuous integration workflows by using GitHub Actions](/learn/modules/github-actions-ci/)
- devops
units:
- learn.github.create-custom-github-actions.introduction
- learn.github.create-custom-github-actions.create-custom-github-action
Expand Down
14 changes: 7 additions & 7 deletions github/create-custom-github-actions/knowledge-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ content: |
quiz:
title: Check your knowledge
questions:
- content: "You need to create a custom GitHub Action written in Ruby. Which action type would you choose?"
- content: "You want your action to run in a consistent and reliable environment. Which action type would you choose?"
choices:
- content: "JavaScript action"
isCorrect: false
explanation: "Although you can write actions in JavaScript, Docker container actions are used for other languages."
explanation: "JavaScript actions separate the action code from the environment that is used to run the action."
- content: "Run step"
isCorrect: false
explanation: "Run steps execute terminal commands within a runner."
explanation: "Composite run steps actions allow you to mix multiple shell languages within the same action, not create consistent and reliable environments."
- content: "Docker container action"
isCorrect: true
explanation: "Actions written in a language other than JavaScript must be placed inside of a Docker container."
explanation: "Docker containers package the environment with the GitHub Actions code, meaning the action runs in a consistent and reliable environment."
- content: "Bash script"
isCorrect: false
explanation: "Bash scripts would either need to be run in Docker or as a parameter to a Run step."
explanation: "Bash scripts are a parameter to a Run step, not how your actions run in a consistent and reliable environment."
- content: "Which keywords are required for a valid `action.yml` file?"
choices:
- content: "name, runs, composite"
Expand All @@ -54,6 +54,6 @@ quiz:
- content: echo "::error::message=This is an error message"
isCorrect: false
explanation: "This is improper syntax for a workflow command."
- content: echo "::error::This is an error message::"
- content: echo "::errorThis is an error message::"
isCorrect: false
explanation: "This is improper syntax for a workflow command."
explanation: "This is improper syntax for a workflow command."