Top Related Projects
Tasks for Azure Pipelines
Run your GitHub Actions locally 🚀
Workflow Engine for Kubernetes
Spinnaker is an open source, multi-cloud continuous delivery platform for releasing software changes with high velocity and confidence.
Jenkins X provides automated CI+CD for Kubernetes with Preview Environments on Pull Requests using Cloud Native pipelines from Tekton
Concourse is a container-based continuous thing-doer written in Go.
Quick Overview
The actions/toolkit is a set of packages to help create GitHub Actions. It provides a collection of Node.js packages that simplify the process of building, testing, and releasing GitHub Actions, offering a range of utilities for common tasks such as input/output operations, logging, and interacting with the GitHub API.
Pros
- Simplifies the development of GitHub Actions with ready-to-use utilities
- Provides a consistent and well-documented API for common tasks
- Regularly updated and maintained by GitHub, ensuring compatibility with the latest Actions features
- Offers TypeScript support for improved type safety and developer experience
Cons
- Limited to Node.js, which may not be suitable for all developers or use cases
- Learning curve for developers new to GitHub Actions or Node.js
- Some advanced use cases may require additional libraries or custom code
- Documentation can be overwhelming for beginners due to the breadth of features
Code Examples
- Setting and getting action inputs:
const core = require('@actions/core');
// Set an output
core.setOutput('result', 'success');
// Get an input
const name = core.getInput('name');
console.log(`Hello ${name}!`);
- Using the GitHub API:
const github = require('@actions/github');
const core = require('@actions/core');
async function createIssue() {
const octokit = github.getOctokit(core.getInput('github-token'));
await octokit.rest.issues.create({
owner: 'octocat',
repo: 'Hello-World',
title: 'New issue created by GitHub Action',
body: 'This is an automated issue created using actions/toolkit'
});
}
createIssue();
- Working with the filesystem:
const io = require('@actions/io');
const core = require('@actions/core');
async function createAndCopyFile() {
await io.mkdirP('temp');
await io.writeFile('temp/example.txt', 'Hello, World!');
await io.cp('temp/example.txt', 'output/copied.txt');
core.info('File created and copied successfully');
}
createAndCopyFile();
Getting Started
To start using actions/toolkit in your GitHub Action:
-
Initialize a new Node.js project:
npm init -y
-
Install the required packages:
npm install @actions/core @actions/github @actions/io
-
Create an
action.yml
file to define your action's metadata. -
Create your main JavaScript file (e.g.,
index.js
) and start using the toolkit:const core = require('@actions/core'); const github = require('@actions/github'); try { // Your action logic here core.setOutput('time', new Date().toTimeString()); } catch (error) { core.setFailed(error.message); }
-
Commit your changes and push to your GitHub repository.
Competitor Comparisons
Tasks for Azure Pipelines
Pros of azure-pipelines-tasks
- More extensive task library with a wider range of pre-built tasks
- Better integration with Azure DevOps and Microsoft ecosystem
- Supports multiple agent types (Windows, Linux, macOS)
Cons of azure-pipelines-tasks
- Steeper learning curve due to more complex architecture
- Less flexibility for custom actions compared to GitHub Actions
- Tighter coupling with Azure DevOps platform
Code Comparison
azure-pipelines-tasks:
steps:
- task: NodeTool@0
inputs:
versionSpec: '14.x'
- script: |
npm install
npm run build
toolkit:
steps:
- uses: actions/setup-node@v2
with:
node-version: '14'
- run: |
npm install
npm run build
The code comparison shows that azure-pipelines-tasks uses a task-based approach, while toolkit relies on reusable actions. The toolkit example is more concise and easier to read, but azure-pipelines-tasks offers more granular control over task execution.
Both repositories provide powerful tools for CI/CD pipelines, but toolkit is more focused on GitHub Actions, while azure-pipelines-tasks is tailored for Azure DevOps. The choice between them depends on the specific platform and requirements of your project.
Run your GitHub Actions locally 🚀
Pros of act
- Allows local testing of GitHub Actions workflows without pushing to a repository
- Simulates the GitHub Actions environment on your local machine
- Supports running specific jobs or entire workflows
Cons of act
- May not perfectly replicate the GitHub Actions environment in all cases
- Requires Docker to be installed and running on the local machine
- Limited support for certain GitHub-specific features and contexts
Code Comparison
act:
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: npm test
toolkit:
import * as core from '@actions/core';
import * as github from '@actions/github';
try {
const nameToGreet = core.getInput('who-to-greet');
console.log(`Hello ${nameToGreet}!`);
} catch (error) {
core.setFailed(error.message);
}
While act focuses on running entire workflows locally, toolkit provides a set of JavaScript packages to create custom actions. act is used for testing and simulating workflows, whereas toolkit is used for developing new actions and interacting with GitHub APIs within those actions.
Workflow Engine for Kubernetes
Pros of Argo Workflows
- Supports complex, multi-step workflows with DAG and step templates
- Provides a web UI for monitoring and managing workflows
- Offers native Kubernetes integration and scalability
Cons of Argo Workflows
- Steeper learning curve due to its complexity
- Requires Kubernetes infrastructure
- Less tightly integrated with GitHub ecosystem
Code Comparison
Argo Workflows (YAML):
apiVersion: argoproj.io/v1alpha1
kind: Workflow
spec:
entrypoint: hello-world
templates:
- name: hello-world
container:
image: docker/whalesay
command: [cowsay]
args: ["Hello World"]
GitHub Actions Toolkit (JavaScript):
const core = require('@actions/core');
const github = require('@actions/github');
try {
console.log('Hello World');
} catch (error) {
core.setFailed(error.message);
}
Key Differences
- Argo Workflows is designed for complex, Kubernetes-based workflows, while GitHub Actions Toolkit is focused on GitHub-specific CI/CD tasks
- Argo Workflows uses YAML for workflow definitions, whereas GitHub Actions Toolkit uses JavaScript
- Argo Workflows provides more advanced features for large-scale, distributed workflows, while GitHub Actions Toolkit offers simpler integration with GitHub repositories and events
Spinnaker is an open source, multi-cloud continuous delivery platform for releasing software changes with high velocity and confidence.
Pros of Spinnaker
- Comprehensive continuous delivery platform for multi-cloud deployments
- Supports complex deployment strategies like canary and blue/green
- Extensive ecosystem with integrations for various cloud providers and tools
Cons of Spinnaker
- Steeper learning curve and more complex setup compared to GitHub Actions
- Requires more infrastructure and maintenance
- Less tightly integrated with GitHub workflows
Code Comparison
Spinnaker (Pipeline JSON):
{
"name": "My Pipeline",
"stages": [
{
"type": "wait",
"name": "Wait",
"waitTime": 30
}
]
}
GitHub Actions (Toolkit):
- name: Wait
uses: actions/github-script@v6
with:
script: |
await new Promise(resolve => setTimeout(resolve, 30000))
Summary
Spinnaker is a powerful, full-featured continuous delivery platform ideal for complex, multi-cloud deployments. It offers advanced deployment strategies but requires more setup and maintenance. The GitHub Actions Toolkit, on the other hand, provides a simpler, more GitHub-centric approach to CI/CD workflows. It's easier to get started with and integrates seamlessly with GitHub, but may lack some of the advanced features and multi-cloud capabilities of Spinnaker.
Jenkins X provides automated CI+CD for Kubernetes with Preview Environments on Pull Requests using Cloud Native pipelines from Tekton
Pros of jx
- Provides a complete CI/CD solution for Kubernetes
- Automates the creation and management of cloud environments
- Integrates with a wide range of tools and platforms
Cons of jx
- Steeper learning curve due to its comprehensive nature
- Requires Kubernetes knowledge and infrastructure
- May be overkill for smaller projects or non-Kubernetes environments
Code Comparison
jx:
jx create cluster gke
jx create quickstart
jx promote --version 1.0.0 --env production
toolkit:
const core = require('@actions/core');
const github = require('@actions/github');
try {
const payload = github.context.payload;
core.setOutput("result", `Action completed for ${payload.repository.name}`);
} catch (error) {
core.setFailed(error.message);
}
Key Differences
- jx focuses on Kubernetes-based CI/CD pipelines, while toolkit is for building GitHub Actions
- jx provides a complete development workflow, whereas toolkit offers building blocks for custom actions
- jx has a CLI-centric approach, while toolkit is primarily used within JavaScript/TypeScript code
- jx is more opinionated about the overall development process, while toolkit is more flexible for various use cases within GitHub Actions
Use Cases
- Choose jx for comprehensive Kubernetes-based CI/CD pipelines and cloud-native development
- Opt for toolkit when building custom GitHub Actions or integrating with GitHub's ecosystem
Concourse is a container-based continuous thing-doer written in Go.
Pros of Concourse
- Provides a complete CI/CD pipeline solution, not just a toolkit
- Offers a visual interface for pipeline management
- Supports multiple languages and platforms out-of-the-box
Cons of Concourse
- Steeper learning curve due to its comprehensive nature
- Requires more infrastructure setup compared to GitHub Actions
- Less integrated with GitHub's ecosystem
Code Comparison
Concourse pipeline definition:
jobs:
- name: hello-world
plan:
- task: say-hello
config:
platform: linux
image_resource:
type: docker-image
source: {repository: ubuntu}
run:
path: echo
args: ["Hello, world!"]
GitHub Actions workflow using Toolkit:
jobs:
hello-world:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Say hello
uses: actions/github-script@v6
with:
script: |
core.setOutput('greeting', 'Hello, world!')
Both examples demonstrate a simple "Hello, world!" task, but Concourse requires more configuration for the same result. The Toolkit approach is more concise and integrates seamlessly with GitHub's environment.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
GitHub Actions Toolkit
The GitHub Actions ToolKit provides a set of packages to make creating actions easier.
Get started with the javascript-action template!
Packages
:heavy_check_mark: @actions/core
Provides functions for inputs, outputs, results, logging, secrets and variables. Read more here
$ npm install @actions/core
:runner: @actions/exec
Provides functions to exec cli tools and process output. Read more here
$ npm install @actions/exec
:ice_cream: @actions/glob
Provides functions to search for files matching glob patterns. Read more here
$ npm install @actions/glob
:phone: @actions/http-client
A lightweight HTTP client optimized for building actions. Read more here
$ npm install @actions/http-client
:pencil2: @actions/io
Provides disk i/o functions like cp, mv, rmRF, which etc. Read more here
$ npm install @actions/io
:hammer: @actions/tool-cache
Provides functions for downloading and caching tools. e.g. setup-* actions. Read more here
See @actions/cache for caching workflow dependencies.
$ npm install @actions/tool-cache
:octocat: @actions/github
Provides an Octokit client hydrated with the context that the current action is being run in. Read more here
$ npm install @actions/github
:floppy_disk: @actions/artifact
Provides functions to interact with actions artifacts. Read more here
$ npm install @actions/artifact
:dart: @actions/cache
Provides functions to cache dependencies and build outputs to improve workflow execution time. Read more here
$ npm install @actions/cache
:lock_with_ink_pen: @actions/attest
Provides functions to write attestations for workflow artifacts. Read more here
$ npm install @actions/attest
Creating an Action with the Toolkit
:question: Choosing an action type
Outlines the differences and why you would want to create a JavaScript or a container based action.
:curly_loop: Versioning
Actions are downloaded and run from the GitHub graph of repos. This contains guidance for versioning actions and safe releases.
:warning: Problem Matchers
Problem Matchers are a way to scan the output of actions for a specified regex pattern and surface that information prominently in the UI.
:warning: Proxy Server Support
Self-hosted runners can be configured to run behind proxy servers.
Hello World JavaScript Action
Illustrates how to create a simple hello world javascript action.
...
const nameToGreet = core.getInput('who-to-greet');
console.log(`Hello ${nameToGreet}!`);
...
JavaScript Action Walkthrough
Walkthrough and template for creating a JavaScript Action with tests, linting, workflow, publishing, and versioning.
async function run() {
try {
const ms = core.getInput('milliseconds');
console.log(`Waiting ${ms} milliseconds ...`)
...
PASS ./index.test.js
â throws invalid number
â wait 500 ms
â test runs
Test Suites: 1 passed, 1 total
Tests: 3 passed, 3 total
TypeScript Action Walkthrough
Walkthrough creating a TypeScript Action with compilation, tests, linting, workflow, publishing, and versioning.
import * as core from '@actions/core';
async function run() {
try {
const ms = core.getInput('milliseconds');
console.log(`Waiting ${ms} milliseconds ...`)
...
PASS ./index.test.js
â throws invalid number
â wait 500 ms
â test runs
Test Suites: 1 passed, 1 total
Tests: 3 passed, 3 total
Docker Action Walkthrough
Create an action that is delivered as a container and run with docker.
FROM alpine:3.10
COPY LICENSE README.md /
COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
Docker Action Walkthrough with Octokit
Create an action that is delivered as a container which uses the toolkit. This example uses the GitHub context to construct an Octokit client.
FROM node:slim
COPY . .
RUN npm install --production
ENTRYPOINT ["node", "/lib/main.js"]
const myInput = core.getInput('myInput');
core.debug(`Hello ${myInput} from inside a container`);
const context = github.context;
console.log(`We can even get context data, like the repo: ${context.repo.repo}`)
Contributing
We welcome contributions. See how to contribute.
Code of Conduct
See our code of conduct.
Top Related Projects
Tasks for Azure Pipelines
Run your GitHub Actions locally 🚀
Workflow Engine for Kubernetes
Spinnaker is an open source, multi-cloud continuous delivery platform for releasing software changes with high velocity and confidence.
Jenkins X provides automated CI+CD for Kubernetes with Preview Environments on Pull Requests using Cloud Native pipelines from Tekton
Concourse is a container-based continuous thing-doer written in Go.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot