Skip to content

Commit

Permalink
Set up action
Browse files Browse the repository at this point in the history
  • Loading branch information
simontollstern committed Jun 24, 2020
1 parent fc72010 commit 84bd195
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 22 deletions.
26 changes: 16 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
# hekto-github-action
Github action for Hekto CI/CD
# Hekto Deployer
Github action for Hekto CI/CD.

This action prints "Hello World" or "Hello" + the name of a person to greet to the log.
Automatic deployment of branches to Hekto.

This action assumes that the application has already been prepared for deployment. Use this action after other actions that builds the application.

## Inputs

### `who-to-greet`
### `token`

**Required** Token for authorization. Can be found on your Hekto profile page.

**Required** The name of the person to greet. Default `"World"`.
### `source`

## Outputs
The source folder to deploy. Default `/`.

### `time`
### `url`

The time we greeted you.
For development purposes. Specifies what url the action should target. Default `https://hekto.app`.

## Example usage

uses: actions/hello-world-docker-action@v1
```
uses: standout/hekto-deployer@v1
with:
who-to-greet: 'Mona the Octocat'
token: 'ukBGtVBVk1uCEgZhayJkjxMsaBwM9H72dXe5ULW1AgFyTvBo'
```
24 changes: 15 additions & 9 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
name: 'Hello World'
description: 'Greet someone and record the time'
name: 'Hekto Deployer'
description: 'Deploy to Hekto'
inputs:
who-to-greet: # id of input
description: 'Who to greet'
token:
description: 'token'
required: true
default: 'World'
outputs:
time: # id of output
description: 'The time we greeted you'
source:
description: 'source'
required: false
default: './'
url:
description: 'url'
reqired: false
default: 'https://hekto.app'
runs:
using: 'docker'
image: 'Dockerfile'
args:
- ${{ inputs.who-to-greet }}
- ${{ inputs.token }}
- ${{ inputs.source }}
- ${{ inputs.url }}
34 changes: 31 additions & 3 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,33 @@
#!/bin/sh -l

echo "Hello $1"
time=$(date)
echo "::set-output name=time::$time"
echo "Token: $1"
echo "Source: $2"
echo "Url: $3"

apk add curl
apk add git
apk add jq

file_name="package.tar.gz"
tar -zcvf $file_name $2
git_hash=$(git rev-parse --short "$GITHUB_SHA")
file_size=$(stat -c%s "$file_name")

echo $file_name
echo $file_size
echo $git_hash

response=$(curl -X POST -d file_name=$file_name -d file_size=$file_size -d commit=$git_hash $3/sv/api/v1/deployment -H "Authorization: Bearer $1")

echo $response > response.json
url=$(jq -r '.url' response.json)
deployment=$(jq -r '.deployment' response.json)

echo $url
echo $deployment

s3_response=$(curl -T $file_name $url)
echo $s3_response

curl=$(curl -X PUT $3/sv/api/v1/deployment/$deployment -H "Authorization: Bearer $1")
echo $curl

0 comments on commit 84bd195

Please sign in to comment.