Build your own GitHub Action WITHOUT a Docker Container
Tags: github, devops, githubactions
Published: 2021-02-18 15:47:39

GitHub shipped "[composite run steps](https://docs.github.com/en/actions/creating-actions/creating-a-composite-run-steps-action)" for the action.yml. This allows developers to build Actions with bash scripts (and other languages too, but more on that at the end).

When GitHub Actions initially shipped in 2018, knowledge of Docker made building your actions more comfortable. By building GitHub Actions I learned Docker is a lot like a Makefile (don't @ me), but even if you don't understand Docker, you now only need to know enough to copy and paste bash from Stackoverflow into your action.yml.

I recently moved my [bdougie/take-action](https://github.com/bdougie/take-action) to run out of the yml and not look back. [Here is that PR](https://github.com/bdougie/take-action/pull/2/files).

```yml

name: contributor-takes-action
description: This is an action to assign yourself to an issue for a repo you are not a contributor to.
author: Brian Douglas
branding:
  icon: 'thumbs-up'
  color: 'white'


runs:
  using: "composite"
  steps:
    -
      run: |
        BODY="$(jq '.comment.body' $GITHUB_EVENT_PATH)"
        ISSUE_NUMBER="$(jq '.issue.number' $GITHUB_EVENT_PATH)"
        LOGIN="$(jq '.comment.user.login' $GITHUB_EVENT_PATH | tr -d \")"
        REPO="$(jq '.repository.full_name' $GITHUB_EVENT_PATH | tr -d \")"
        if [[ $BODY == *".take"* ]]; then
          echo "Assigning issue $ISSUE_NUMBER to $LOGIN"
          echo "Using the link: https://api.github.com/repos/$REPO/issues/$ISSUE_NUMBER/assignees"
          curl -H "Authorization: token $GITHUB_TOKEN" -d '{"assignees":["'"$LOGIN"'"]}' https://api.github.com/repos/$REPO/issues/$ISSUE_NUMBER/assignees
        fi
      shell: bash
```

So now the action only needs an action.yml to run. The setup is similar to workflow yamls in repositories, which means you can also run ruby, node, or any other language scripts if you would like. In the steps, including the corresponding setup action. What the composite run steps do. It can now add steps similar to the way you add action steps in your workflows inside your repositories.

```yml
// example running a ruby script

runs:
  using: "composite"
  steps:
    - uses: actions/checkout@v2
      with:
        ref: ${{ github.head_ref }}
    - name: Set up Ruby
      uses: ruby/setup-ruby@v1
      with:
        ruby-version: 2.6.5
    - name: Bundle install
      run: |
        bundle install --jobs 4 --retry 3
    - name: create-readme
      run: |
        bundle exec ruby create-readme.rb
      shell: bash
```

The most significant difference is that this setup is not in my repo workflow but now in a re-usable format. I no longer need to rewrite the script every time I want to have this run in a new project. I also don't need the full-on maintenance required to maintain this batch script.

And I want to shout out crazy-max, who walked me through this on my previous trip Twitch stream. If you are interested in watching me build actions from scratch, I stream it for Tuesday and Friday, live on Twitch. And also, shout out to [crazy-max](https://github.com/crazy-max), who is a prolific action creator. He's got quite a few different actions that I use every day, including deploying your site to GitHub pages.

_This is part of my 28 days of Actions series. To get notified of more GitHub Action tips, follow the GitHub organization right here on Dev. Learn how to build action with Node.js_

{% link https://dev.to/github/generate-your-own-github-action-with-the-actions-toolkit-cli-1lno %}