diff --git a/README.md b/README.md index 69780f6..c1d8261 100644 --- a/README.md +++ b/README.md @@ -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' +``` diff --git a/action.yml b/action.yml index 9b136f8..88628fe 100644 --- a/action.yml +++ b/action.yml @@ -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 }} diff --git a/entrypoint.sh b/entrypoint.sh index 7636076..0a258e1 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -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