Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
Initial commit

-

docs: add example
  • Loading branch information
philipparndt committed Sep 6, 2024
0 parents commit 3b786ed
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
max_line_length = 120
tab_width = 4
23 changes: 23 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: CI

on:
workflow_dispatch:
push:
schedule:
- cron: "0 */3 * * *"

jobs:
test:
runs-on: ubuntu-latest
steps:

- name: Checkout
uses: actions/checkout@v4

- name: Setup veHub
uses: ./

- name: Check installation
shell: bash
run: |
vehub --version
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea/
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# setup-vehub

This action sets up the veHub CLI, so that it can be used in subsequent steps.

## Usage

Example usage:

```yaml
steps:
- name: Setup veHub CLI
uses: vehub/setup-vehub@v1

- name: Check installation
run: vehub --version

- name: List project spaces
run: vehub space list
env:
VEHUB_TOKEN: ${{ secrets.VEHUB_TOKEN }}
```
11 changes: 11 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: 'Setup veHub'
description: 'This action sets up the veHub CLI by downloading the latest version.'
author: 'Vector Informatik GmbH'

runs:
using: composite
steps:
- name: Greet and Record Time # name of step
id: greet
run: ${{ github.action_path }}/setup-vehub.sh
shell: bash
40 changes: 40 additions & 0 deletions setup-vehub.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env bash
set -e

# Central installation directory
INSTALL_DIR="/usr/local/bin"

echo "Downloading veHub CLI..."
DATA=$(curl -s 'https://search.vector.com/at-de/_search/' \
-H 'content-type: application/json' \
-H 'user-agent: Mozilla/5.0 (X11; Linux x86_64) Chrome/115.0.5790.102' \
--data-raw '{"from":0,"size":45,"query":{"function_score":{"score_mode":"first","boost_mode":"multiply","query":{"bool":{"should":[],"filter":[{"match":{"type":{"query":"downloads","boost":1,"operator":"AND"}}}],"must":[{"terms":{"downloadType":["freeware","demos","drivers","service"]}},{"terms":{"categoryProductDefaultLang":["69969"]}}]}}}},"explain":false,"sort":[{"sortdate":"desc"}]}')

LATEST_VERSION=$(echo $DATA | jq '[.hits.hits[] | select(._source.operatingSystem == "1")][0] | ._source | {title: .title, version: .version, url: .url}')
echo $LATEST_VERSION | jq '{title: .title, version: .version}'

URL=$(echo $LATEST_VERSION | jq -r '.url | fromjson | .downloadAction' | head -n 1)

echo "Downloading from $URL..."

curl -L "https://vector.com$URL" \
-H 'content-type: application/json' \
-H 'user-agent: Mozilla/5.0 (X11; Linux x86_64) Chrome/115.0.5790.102' -o cli.zip

echo "Extracting veHub CLI..."
unzip cli.zip -d cli

# Make the binary executable
chmod +x cli/vehub

# Move the binary to /usr/local/bin to make it globally accessible
sudo mv cli/vehub "$INSTALL_DIR"

# Verify installation
if command -v vehub &> /dev/null
then
echo "veHub CLI installed successfully at $(command -v vehub)"
else
echo "veHub CLI installation failed!"
exit 1
fi

0 comments on commit 3b786ed

Please sign in to comment.