Skip to content
git-branch

GitHub Action

Push pre-built JavaScript / TypeScript / Docker container GitHub Action

v0.2.0-beta3 Latest version

Push pre-built JavaScript / TypeScript / Docker container GitHub Action

git-branch

Push pre-built JavaScript / TypeScript / Docker container GitHub Action

Speed up CI execution time by pre-building

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Push pre-built JavaScript / TypeScript / Docker container GitHub Action

uses: satackey/[email protected]

Learn more about this action in satackey/push-prebuilt-action

Choose a version

Push pre-built JS/TS/Docker GitHub Action

This GitHub action reduces CI execution time by pre-building JavaScript, TypeScript, and Docker container actions.

What does this action do to make it pre-built?

JavaScript / TypeScript action

This action compiles JavaScript GitHub Action into a single file (with cache files if you want), and pushes it to GitHub. Compilation is powered by zeit/ncc.

TypeScript is also supported. Specify your *.ts file to action.yml#runs.main

Since there is no need to commit node_modules, your GitHub Action can be released quickly with less time for pushes during action development and pulls during CI execution.

This Action written in TypeScript has been compiled by itself and released. See pre-built commit

Docker container action

This action builds an image from your Dockerfile, and pushes it to the Docker registry, and rewrites action.yml#rans.image by pushed tag.

The job just pulls Docker image when using the action, and there's no time to build the Dockerfile.

Usage

The description action.yml can be read as action.yaml.

JavaScript / TypeScript

Example (Step only)

    - uses: satackey/[email protected]
      with:
        push-branch: release-master

Click here to see workflow example

Basic flow

  1. This action detects that your action is a JS/TS action by action.yml
  2. This action compiles a file (e.g. index.js) specified in action.yml#runs.main into dist/index.js
  3. Replaces the value of runs.main with dist/index.js.
  4. Remove files exclude /action.yml and dist/*.
  5. Checkout a new branch with the name specified in push-branch.
  6. Commit all changes.
  7. Force push new branch (and tags) to the origin

Basic inputs

  • push-branch Required
    The name of branch to push compiled file.
  • release-tags optional
    The names to tag the compiled file commit.
  • commit-message optional, default: [auto]
    The commit message for the compiled.

Advanced configrations

Click here to expand
  • committer-name Required
    default: github-actions
    The name to set as git user.name.
  • committer-email Required
    default: [email protected]
    The email to set as git user.email.
  • execlude-from-cleanup Required
    default: action.yml action.yaml dist .git
    Files/dirs to leave for commit.
  • force-push Required
    default: 'true'
    Whether to force push to branch or tags. Either 'true' or 'false'.

  • js-build-command Required
    default: ncc build --v8-cache {main}
    The command and arguments to build JavaScript or TypeScript files. The artifacts must be in the dist/ directory and entrypoint must be dist/index.js.

Docker container

Example (step only)

    - uses: satackey/[email protected]
      with:
        push-branch: release-<your_branch_name>
        docker-registry: docker.io
        docker-user: <your_dockerhub_username>
        docker-token: <your_dockerhub_access_token>
        docker-repotag: <your_repo>:${{ github.sha }}

Click here to see workflow example

Basic flow

  1. This action detects that your action is a Docker container action by action.yml
  2. This action builds the Dockerfile specifed in action.yml#runs.image
  3. Replaces the value of runs.image with docker://<docker-repotag>.
  4. Remove files exclude /action.yml.
  5. Checkout a new branch with the name specified in push-branch.
  6. Commit all changes.
  7. Push the Docker image <docker-repotag> to the Docker registry <docker-registry>.
  8. Force push new branch (and tags) to the origin

Basic inputs

  • push-branch Required
    The name of branch to push compiled file.
  • release-tags optional
    The names to tag the compiled file commit.
  • commit-message optional, default: [auto]
    The commit message for the compiled.

  • docker-registry Required
    The Docker registry's repository of push action image.

  • docker-repotag Required
    The Docker registry's repository of push action image.

  • docker-user Required
    The username to login to the Docker registry.

  • docker-token Required
    The token to login to the Docker registry.

Advanced configrations

Click here to expand
  • committer-name Required
    default: github-actions
    The name to set as git user.name.
  • committer-email Required
    default: [email protected]
    The email to set as git user.email.
  • execlude-from-cleanup Required
    default: action.yml action.yaml dist .git
    Files/dirs to leave for commit.
  • force-push Required
    default: 'true'
    Whether to force push to branch or tags. Either 'true' or 'false'.

  • docker-build-command Required
    default: 'true'
    The command and arguments to build Docker image.

Contribution

PRs are accepted.

If you are having trouble or feature request, post new issue.

Workflow Examples

JavaScript / TypeScript action example

name: Push pre-built action

on:
  push:
    branches:
    - '**'

jobs:
  build_and_push:
    runs-on: ubuntu-latest

    steps:
    - name: Setup node.js
      uses: actions/setup-node@v1
      with:
        node-version: 12.x

    - name: Checkout
      uses: actions/checkout@v2

    - name: Output branch name
      id: name
      run: echo "##[set-output name=branch;]${GITHUB_REF#refs/heads/}"

    - name: Push
      uses: satackey/[email protected]
      with:
        push-branch: release-${{ steps.name.outputs.branch }}
        # [optional] The commit can be tagged.
        # release-tags: v1 v1.0 v1.0.0
        # [optional] You can change he commit message.
        # commit-message: '[ci skip]'

The distribution is pushed into release-<your_branch> like release-master.

Docker container action example

name: Push pre-built action

on:
  push:
    branches:
    - '**'

jobs:
  build_and_push:
    runs-on: ubuntu-latest

    steps:
    - name: Checkout
      uses: actions/checkout@v2

    - name: Output branch name
      id: name
      run: echo "##[set-output name=branch;]${GITHUB_REF#refs/heads/}"

    - name: Push
      uses: satackey/[email protected]
      with:
        push-branch: release-${{ steps.name.outputs.branch }}
        # [optional] The commit can be tagged.
        # release-tags: v1 v1.0 v1.0.0
        # [optional] You can change he commit message.
        # commit-message: '[ci skip]'
        docker-registry: docker.io
        docker-user: <your_dockerhub_username>
        docker-token: ${{ secrets.DOCKERHUB_TOKEN }} # your dockerhub access token
        docker-repotag: <your_repo>:${{ github.sha }}

The distribution is pushed into release-<your_branch> like release-master.