All Projects → posener → Goaction

posener / Goaction

Licence: apache-2.0
Write Github actions in Go

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects
script
160 projects

Projects that are alternatives of or similar to Goaction

Revert
A GitHub Action to automatically revert a commit on a '/revert' comment
Stars: ✭ 89 (-40.27%)
Mutual labels:  action
Essential Netty In Action
It is a book about the Essentials of Norman Maurer's Netty in Action.《Netty 实战(精髓)》是对 Norman Maurer 的 《Netty in Action》的一个精简
Stars: ✭ 1,502 (+908.05%)
Mutual labels:  action
Github Action Markdown Link Check
Check all links in markdown files if they are alive or dead. 🔗✔️
Stars: ✭ 132 (-11.41%)
Mutual labels:  action
Avaloniabehaviors
Port of Windows UWP Xaml Behaviors for Avalonia Xaml.
Stars: ✭ 96 (-35.57%)
Mutual labels:  action
Action Send Mail
⚙️ A GitHub Action to send an email to multiple recipients
Stars: ✭ 111 (-25.5%)
Mutual labels:  action
Golang Action
A GitHub Action to run Go commands
Stars: ✭ 119 (-20.13%)
Mutual labels:  action
Cachix Action
Build software only once and put it in a global cache
Stars: ✭ 85 (-42.95%)
Mutual labels:  action
Pr Size Labeler
🏷 Visualize and optionally limit the size of your Pull Requests
Stars: ✭ 140 (-6.04%)
Mutual labels:  action
Kicad Action Scripts
Some KiCad plugins in Python
Stars: ✭ 111 (-25.5%)
Mutual labels:  action
Figma Action
Export image assets from Figma to GitHub
Stars: ✭ 134 (-10.07%)
Mutual labels:  action
Customalertviewdialogue
Custom AlertView Dialogue is the world's most advanced alert view library. Custom AlertView Dialogue includes simple message popups, confirmation alerts, selector popups, action sheet bottom menus, and input/feedback contact forms.
Stars: ✭ 100 (-32.89%)
Mutual labels:  action
Action Download Artifact
⚙️ A GitHub Action to download an artifact associated with given workflow and commit or other criteria
Stars: ✭ 107 (-28.19%)
Mutual labels:  action
Zoo
🌈 Cute pet zoo. Come and adopt a cute you like. 萌萌乐园,全自动领养自己喜欢的萌物。
Stars: ✭ 121 (-18.79%)
Mutual labels:  action
Postgresql Action
GitHub Action to setup a PostgreSQL database
Stars: ✭ 91 (-38.93%)
Mutual labels:  action
Release Drafter
Drafts your next release notes as pull requests are merged into master.
Stars: ✭ 2,119 (+1322.15%)
Mutual labels:  action
Sense Navigation
Sheet Navigation + Actions for Qlik Sense.
Stars: ✭ 85 (-42.95%)
Mutual labels:  action
3d Densenet
3D Dense Connected Convolutional Network (3D-DenseNet for action recognition)
Stars: ✭ 118 (-20.81%)
Mutual labels:  action
Upload To Release
A GitHub Action that uploads a file to a new release.
Stars: ✭ 144 (-3.36%)
Mutual labels:  action
Redux Dataloader
Loads async data for Redux apps focusing on preventing duplicated requests and dealing with async dependencies.
Stars: ✭ 139 (-6.71%)
Mutual labels:  action
Laravel Handlers
Request handlers for Laravel
Stars: ✭ 128 (-14.09%)
Mutual labels:  action

goaction

GoDoc

Package goaction enables writing Github Actions in Go.

The idea is: write a standard Go script, one that works with go run, and use it as Github action. The script's inputs - flags and environment variables, are set though the Github action API. This project will generate all the required files for the script (This generation can be done automattically with Github action integration). The library also exposes neat API to get workflow information.

Required Steps

  • [x] Write a Go script.

  • [x] Add goaction configuration in .github/workflows/goaction.yml.

  • [x] Push the project to Github.

See simplest example for a Goaction script: posener/goaction-example, or an example that demonstrait using Github APIs: posener/goaction-issues-example.

Writing a Goaction Script

Write Github Action by writing Go code! Just start a Go module with a main package, and execute it as a Github action using Goaction, or from the command line using go run.

A go executable can get inputs from the command line flag and from environment variables. Github actions should have a action.yml file that defines this API. Goaction bridges the gap by parsing the Go code and creating this file automatically for you.

The main package inputs should be defined with the standard flag package for command line arguments, or by os.Getenv for environment variables. These inputs define the API of the program and goaction automatically detect them and creates the action.yml file from them.

Additionally, goaction also provides a library that exposes all Github action environment in an easy-to-use API. See the documentation for more information.

Code segments which should run only in Github action (called "CI mode"), and not when the main package runs as a command line tool, should be protected by a if goaction.CI { ... } block.

Goaction Configuration

In order to convert the repository to a Github action, goaction command line should run on the "main file" (described above). This command can run manually (by ./cmd/goaction) but luckily goaction also comes as a Github action :-)

Goaction Github action keeps the Github action file updated according to the main Go file automatically. When a PR is made, goaction will post a review explaining what changes to expect. When a new commit is pushed, Goaction makes sure that the Github action files are updated if needed.

Add the following content to .github/workflows/goaction.yml

on:
  pull_request:
    branches: [master]
  push:
    branches: [master]
jobs:
  goaction:
    runs-on: ubuntu-latest
    steps:
    - name: Check out repository
      uses: actions/checkout@v2
    - name: Update action files
      uses: posener/goaction@v1
      with:
        # Optional: required only for commenting on PRs.
        github-token: '${{ secrets.GITHUB_TOKEN }}'
    # Optional: now that the script is a Github action, it is possible to run it in the
    # workflow.
    - name: Example
      uses: [./](./)

Goaction Artifacts

./action.yml: A "metadata" file for Github actions. If this file exists, the repository is considered as Github action, and the file contains information that instructs how to invoke this action. See metadata syntax. for more info.

./Dockerfile: A file that contains instructions how to build a container, that is used for Github actions. Github action uses this file in order to create a container image to the action. The container can also be built and tested manually:

$ docker build -t my-action .
$ docker run --rm my-action

Annotations

Goaction parses Go script file and looks for annotations that extends the information that exists in the function calls. Goaction annotations are a comments that start with //goaction: (no space after slashes). They can only be set on a var definition. The following annotations are available:

  • //goaction:required - sets an input definition to be "required".

  • //goaction:skip - skips an input out output definition.

  • //goaction:description <description> - add description for os.Getenv.

  • //goaction:default <value> - add default value for os.Getenv.

Using Goaction

A list of projects which are using Goaction (please send a PR if your project uses goaction and does not appear her).

Sub Packages

  • actionutil: Package actionutil provides utility functions for Github actions.

  • log: Package log is an alternative package for standard library "log" package for logging in Github action environment.


Readme created from Go doc with goreadme

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].