Skip to content
This repository has been archived by the owner on Jun 13, 2021. It is now read-only.

Commit

Permalink
First commit (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
superbrothers authored Feb 11, 2020
1 parent be54b47 commit 48ae73c
Show file tree
Hide file tree
Showing 20 changed files with 7,002 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/node_modules
/dist
20 changes: 20 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended",
"prettier/@typescript-eslint"
],
"plugins": [
"@typescript-eslint"
],
"env": { "node": true, "es6": true },
"parser": "@typescript-eslint/parser",
"parserOptions": {
"sourceType": "module",
"project": "./tsconfig.json"
},
"rules": {
}
}
17 changes: 17 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: CI

on:
push:
branches: [master]
pull_request:
types: [opened, synchronize]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
- run: make image
- run: bin/ga --help
47 changes: 47 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Release

on:
push:
tags: ["v*"]

jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
- uses: azure/docker-login@v1
with:
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- run: make image push-image
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: make dist
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
- uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ga.zip
asset_name: ga.zip
asset_content_type: application/zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ga.zip.sha256
asset_name: ga.zip.sha256
asset_content_type: text/plain
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/dist
/node_modules
/ga.zip
21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
ARG NODE_VERSION=

FROM node:${NODE_VERSION}
WORKDIR /app
COPY package*.json ./
RUN set -x && npm install
COPY . .
RUN set -x && \
apt-get update -qq && \
apt-get install -qy jq && \
make verify && \
npm run lint && \
npm run test && \
npm run build

FROM node:${NODE_VERSION}-slim
COPY package*.json ./
RUN set -x && npm install --only=production
COPY --from=0 /app/dist/src /app
COPY LICENSE /app/LICENSE
ENTRYPOINT ["node", "/app/index.js"]
39 changes: 39 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
The MIT License (MIT)

Copyright (c) 2020 Kazuki Suda <kazuki.suda@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

This repository contains the code which has the following license
notice:

Copyright 2016 The Kubernetes Authors All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
37 changes: 37 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
NODE_VERSION ?= 12
NODE_IMAGE := node:$(NODE_VERSION)
DOCKER_RUN := docker run --rm -v "$${PWD}:/app" -w /app -it $(NODE_IMAGE)
NPM ?= $(DOCKER_RUN) npm
VERSION := $(shell cat package.json | jq -r '.version')
IMAGE := docker.io/superbrothers/ga:$(VERSION)

.PHONY: image
image:
DOCKER_BUILDKIT=1 docker build --build-arg NODE_VERSION=$(NODE_VERSION) -t $(IMAGE) .

.PHONY: push-image
push-image:
doker push $(IMAGE)

.PHONY: dist
dist:
zip ga.zip README.md LICENSE bin/ga
shasum -a 256 ga.zip | awk '{print $$1}' > ga.zip.sha256

.PHONY: update
update:
@./hack/update-readme.sh
@./hack/update-bin.sh

.PHONY: verify
verify:
@./hack/verify-readme.sh
@./hack/verify-bin.sh

.PHONY: clean
clean:
$(RM) ga.zip ga.zip.sha256

.PHONY: run-in-node
run-in-node:
$(DOCKER_RUN) /bin/bash
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# `ga`: The GitHub Actions helper command-line tool

This tool provides for setting results, logging, registering secrets and exporting variables across actions.

## Usage

```
Usage: ga [options] [command]
The GitHub Actions helper command-line tool.
Options:
-v, --version Print the version information
-h, --help output usage information
Commands:
set-env <name> <value> Sets env variable for this action and future
actions in the job.
set-secret <secret> Registers a secret which will get masked from
logs
add-path <path> Prepends inputPath to the PATH (for this action
and future actions).
get-input [options] <name> Gets the value of an input. The value is also
trimmed.
set-output <name> <value> Sets the value of an output
set-failed <message> Sets the action status to failed.
debug <message> Writes debug message to user log
error <message> Adds an error issue
warning <message> Adds an warning issue
info <message> Writes info to log with console.log
start-group <name> Begin an output group
end-group End an output group
save-state <name> <value> Saves state for current action, the state can
only be retrieved by this action's post job
execution.
get-state <name> Gets the value of an state set by this action's
main execution.
*
```

## License

This software is released under the MIT license.
9 changes: 9 additions & 0 deletions bin/ga
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

set -e -o pipefail; [[ -n "$DEBUG" ]] && set -x

GA_VERSION="${GA_VERSION:-0.1.0}"
GA_IMAGE="${GA_IMAGE:-"docker.io/superbrothers/ga:${GA_VERSION}"}"

exec docker run "${GA_IMAGE}" "${@}"
# vim: ai ts=2 sw=2 et sts=2 ft=sh
9 changes: 9 additions & 0 deletions hack/ga
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

set -e -o pipefail; [[ -n "$DEBUG" ]] && set -x

GA_VERSION="${GA_VERSION:-__VERSION__}"
GA_IMAGE="${GA_IMAGE:-"docker.io/superbrothers/ga:${GA_VERSION}"}"

exec docker run "${GA_IMAGE}" "${@}"
# vim: ai ts=2 sw=2 et sts=2 ft=sh
10 changes: 10 additions & 0 deletions hack/update-bin.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

set -e -o pipefail; [[ -n "$DEBUG" ]] && set -x

SCRIPT_ROOT="$(cd $(dirname $0); pwd)"
TARGET_FILE="${TARGET_FILE:-"${SCRIPT_ROOT}/../bin/ga"}"

version="$(cat "${SCRIPT_ROOT}/../package.json" | jq -r ".version")"
sed -e "s/__VERSION__/${version}/" "${SCRIPT_ROOT}/ga" >"$TARGET_FILE"
# vim: ai ts=2 sw=2 et sts=2 ft=sh
25 changes: 25 additions & 0 deletions hack/update-readme.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash

set -e -o pipefail; [[ -n "$DEBUG" ]] && set -x

SCRIPT_ROOT="$(cd $(dirname $0); pwd)"

TARGET_FILE="${TARGET_FILE:-"${SCRIPT_ROOT}/../README.md"}"
cat <<'EOL' >"$TARGET_FILE"
# `ga`: The GitHub Actions helper command-line tool
This tool provides for setting results, logging, registering secrets and exporting variables across actions.
## Usage
```
EOL
npm run --silent start -- --help >>"$TARGET_FILE"
cat <<'EOL' >>"$TARGET_FILE"
```
## License
This software is released under the MIT license.
EOL
# vim: ai ts=2 sw=2 et sts=2 ft=sh
25 changes: 25 additions & 0 deletions hack/verify-bin.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash

set -e -o pipefail; [[ -n "$DEBUG" ]] && set -x

SCRIPT_ROOT="$(cd $(dirname $0); pwd)"

tmp_root="$(mktemp -d)"
cleanup() {
rm -rf "$tmp_root"
}
trap "cleanup" EXIT SIGINT

export TARGET_FILE="${tmp_root}/ga"
"${SCRIPT_ROOT}/update-bin.sh"

ret=0
diff "${SCRIPT_ROOT}/../bin/ga" "${TARGET_FILE}" || ret=$?

if [[ $ret -eq 0 ]]; then
echo "bin/ga is up to date."
else
echo "bin/ga is out of date. Please run hack/update-readme.sh."
exit 1
fi
# vim: ai ts=2 sw=2 et sts=2 ft=sh
25 changes: 25 additions & 0 deletions hack/verify-readme.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash

set -e -o pipefail; [[ -n "$DEBUG" ]] && set -x

SCRIPT_ROOT="$(cd $(dirname $0); pwd)"

tmp_root="$(mktemp -d)"
cleanup() {
rm -rf "$tmp_root"
}
trap "cleanup" EXIT SIGINT

export TARGET_FILE="${tmp_root}/README.md"
"${SCRIPT_ROOT}/update-readme.sh"

ret=0
diff "${SCRIPT_ROOT}/../README.md" "${TARGET_FILE}" || ret=$?

if [[ $ret -eq 0 ]]; then
echo "README.md is up to date."
else
echo "README.md is out of date. Please run hack/update-readme.sh."
exit 1
fi
# vim: ai ts=2 sw=2 et sts=2 ft=sh
Loading

0 comments on commit 48ae73c

Please sign in to comment.