Initial commit
This commit is contained in:
commit
4c9c86015c
|
@ -0,0 +1 @@
|
|||
github: karniv00l
|
|
@ -0,0 +1,6 @@
|
|||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "github-actions"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "daily"
|
|
@ -0,0 +1,13 @@
|
|||
name: Update Major Version Tag
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "v*"
|
||||
|
||||
jobs:
|
||||
update-majorver:
|
||||
name: Update Major Version Tag
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: nowactions/update-majorver@v1
|
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2022 HyperTuner
|
||||
|
||||
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.
|
|
@ -0,0 +1,29 @@
|
|||
# HyperTuner INI upload
|
||||
|
||||
GitHub Action for INI upload.
|
||||
|
||||
## Usage
|
||||
|
||||
`.github/workflows/upload-ini.yml`
|
||||
|
||||
```yaml
|
||||
name: Upload INI
|
||||
|
||||
on: pull_request
|
||||
|
||||
jobs:
|
||||
upload:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- name: Upload INI
|
||||
uses: hyper-tuner/ini-upload-action@v1
|
||||
with:
|
||||
api-url: "https://api.hypertuner.cloud"
|
||||
username: "admin-uploader@example.com"
|
||||
password: "danger-to-manifold"
|
||||
path: "path/to.ini"
|
||||
ecosystem: "speeduino"
|
||||
```
|
|
@ -0,0 +1,111 @@
|
|||
name: HyperTuner INI upload
|
||||
description: GitHub Action for INI upload.
|
||||
author: Piotr Rogowski <piotr.rogowski0@gmail.com>
|
||||
branding:
|
||||
icon: cpu
|
||||
color: blue
|
||||
inputs:
|
||||
api-url:
|
||||
description: 'HyperTuner API URL'
|
||||
required: true
|
||||
username:
|
||||
description: 'HyperTuner admin username'
|
||||
required: true
|
||||
|
||||
password:
|
||||
description: 'HyperTuner admin password'
|
||||
required: true
|
||||
|
||||
path:
|
||||
description: 'Path to INI file'
|
||||
required: true
|
||||
|
||||
ecosystem:
|
||||
description: 'Either "speeduino" or "rusefi"'
|
||||
required: true
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: Upload
|
||||
shell: bash
|
||||
run: |
|
||||
API_URL=${{ inputs.api-url }}
|
||||
USERNAME=${{ inputs.username }}
|
||||
PASSWORD=${{ inputs.password }}
|
||||
INI_PATH=${{ inputs.path }}
|
||||
ECOSYSTEM=${{ inputs.ecosystem }}
|
||||
|
||||
upload_url="${API_URL}/api/collections/iniFiles/records"
|
||||
auth_url="${API_URL}/api/admins/auth-with-password"
|
||||
|
||||
echo "Parsing signature..."
|
||||
|
||||
signature=$(awk -F "=" '/signature/ {print $2}' ${INI_PATH} | tr -d '"' | xargs)
|
||||
|
||||
echo "Signature: ${signature}"
|
||||
|
||||
echo "Compressing..."
|
||||
|
||||
mkdir gzipped
|
||||
gzip --best --keep ${INI_PATH}
|
||||
mv ${INI_PATH}.gz gzipped/${signature}.ini
|
||||
|
||||
args=()
|
||||
args+="--silent"
|
||||
args+=${auth_url}
|
||||
args+="--header 'Content-Type: application/json'"
|
||||
args+="--data-raw '{\"identity\": \"${USERNAME}\", \"password\": \"${PASSWORD}\"}'"
|
||||
|
||||
echo "Authenticating..."
|
||||
|
||||
token=$(echo $args | xargs curl | jq -r '.token')
|
||||
|
||||
echo "Checking if file already exists..."
|
||||
|
||||
args=()
|
||||
args+="--silent"
|
||||
args+="--get"
|
||||
args+="${upload_url}"
|
||||
args+="--header 'Authorization: Bearer ${token}'"
|
||||
args+="--data-urlencode 'filter=signature=\"${signature}\"'"
|
||||
|
||||
response=$(echo $args | xargs curl)
|
||||
|
||||
found=$(echo $response | jq '.totalItems')
|
||||
|
||||
args=()
|
||||
args+="--silent"
|
||||
args+="--header 'Authorization: Bearer ${token}'"
|
||||
args+="--form 'signature=\"${signature}\"'"
|
||||
args+="--form 'ecosystem=\"${ECOSYSTEM}\"'"
|
||||
args+="--form 'file=@"gzipped/${signature}.ini"'"
|
||||
|
||||
if [[ $found == 0 ]]; then
|
||||
echo "Not found"
|
||||
echo "Trying to create a new record..."
|
||||
|
||||
args+="${upload_url}"
|
||||
args+="--request POST"
|
||||
|
||||
response=$(echo $args | xargs curl)
|
||||
else
|
||||
echo "Record already exists, trying to update..."
|
||||
id=$(echo $response | jq -r '.items[0].id')
|
||||
|
||||
args+="${upload_url}/${id}"
|
||||
args+="--request PATCH"
|
||||
|
||||
response=$(echo $args | xargs curl)
|
||||
fi
|
||||
|
||||
error=$(echo $response | jq -r '.code')
|
||||
|
||||
if [ -z "$error" ]
|
||||
then
|
||||
echo "Error: $response"
|
||||
exit 1
|
||||
else
|
||||
echo "Success"
|
||||
exit 0
|
||||
fi
|
Loading…
Reference in New Issue