Skip to content

Commit

Permalink
feat: add install script and simple action definition (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
zepatrik authored Nov 20, 2020
1 parent edfa7e8 commit 7a98727
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
.bin
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,22 @@ A GitHub action that provides [buf](https://github.com/bufbuild/buf).

## Usage

TODO
```yaml
name: Generate and Lint buf

on:
pull_request:
branches:
- *

jobs:
lint:
name: buf check lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ory/build-buf-action@v0
with:
bufVersion: v0.31.1
bufArgs: check lint --config buf/api/buf.yaml
```
21 changes: 20 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,27 @@
name: Build Buf
description: A GitHub action that provides buildbuf/buf

inputs:
bufVersion:
description: The version of buf to use (as in their GitHub releases)
default: v0.31.1
required: false
bufArgs:
description: The arguments to pass to buf
default: generate
required: false

runs:
using: composite
steps: [ ]
steps:
# requires actions within actions as tracked in https://github.com/actions/runner/issues/646
# - uses: actions/cache@v2
- name: Maybe install and definitely invoke buf
shell: bash
run: |
source scripts/install-buf.sh ${{ inputs.bufVersion }}
buf ${{ inputs.bufArgs }}
branding:
color: blue
icon: box
19 changes: 19 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "build-buf-action",
"private": true,
"description": "A GitHub action that provides [buf](https://github.com/bufbuild/buf).",
"main": "index.js",
"prettier": "ory-prettier-styles",
"config": {
"prettierTarget": "{*.yml,*.md}"
},
"scripts": {
"format": "prettier --write ${npm_package_config_prettierTarget}",
"format:check": "prettier --check ${npm_package_config_prettierTarget}"
},
"repository": {
"type": "git",
"url": "git+https://github.com/ory/build-buf-action.git"
},
"bugs": {
"url": "https://github.com/ory/build-buf-action/issues"
},
"homepage": "https://github.com/ory/build-buf-action#readme",
"devDependencies": {
"ory-prettier-styles": "^1.1.1",
"prettier": "^2.2.0"
}
}
17 changes: 17 additions & 0 deletions scripts/install-buf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
set -euo pipefail

UNAME_OS=$(uname -s)
UNAME_ARCH=$(uname -m)

BUF_VERSION=$1

if [ ! -f ".bin/buf" ]; then
echo "Installing buf $BUF_VERSION for OS $UNAME_OS Arch $UNAME_ARCH"
mkdir -p .bin
curl --fail -sSL "https://github.com/bufbuild/buf/releases/download/$BUF_VERSION/buf-$UNAME_OS-$UNAME_ARCH" -o .bin/buf
chmod +x .bin/buf
fi

PATH=PATH:"$(pwd)/.bin"
export PATH

0 comments on commit 7a98727

Please sign in to comment.