Skip to content

Commit

Permalink
Merge pull request #1 from nicolaferraro/fix-mac-os
Browse files Browse the repository at this point in the history
Fix CI
  • Loading branch information
nicolaferraro authored Jul 14, 2021
2 parents 6da1ad3 + f4cd37b commit c7916f8
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 2 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,20 @@ on:

jobs:

test-smoke:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1

- name: Install Camel K
uses: ./

- name: Test
shell: bash
run: |
kamel version
test-default:
strategy:
matrix:
Expand All @@ -24,6 +38,8 @@ jobs:

- name: Install Camel K
uses: ./
with:
github_token: "${{ secrets.GITHUB_TOKEN }}"

- name: Test
shell: bash
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ For more information, reference the GitHub Help Documentation for [Creating a wo
For more information on inputs, see the [API Documentation](https://developer.github.com/v3/repos/releases/#input)

- `version`: The Camel K version to use (default: `latest`)
- `github_token`: Optional token used when fetching the latest Camel K release to avoid hitting rate limits (you should set it to `${{ secrets.GITHUB_TOKEN }}`)

### Example Workflow

Expand Down
2 changes: 2 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ branding:
inputs:
version:
description: "The Camel K version to use (default: latest)"
github_token:
description: "Optional token used when fetching the latest Camel K release to avoid hitting rate limits"
runs:
using: "node12"
main: "main.js"
28 changes: 26 additions & 2 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ set -o errexit
set -o nounset
set -o pipefail

set -x

DEFAULT_VERSION=latest

show_help() {
Expand All @@ -30,7 +32,8 @@ EOF

main() {
local version="$DEFAULT_VERSION"

local github_token=

parse_command_line "$@"

install_camel_k
Expand All @@ -54,6 +57,16 @@ parse_command_line() {
exit 1
fi
;;
--github-token)
if [[ -n "${2:-}" ]]; then
github_token="$2"
shift
else
echo "ERROR: '--github-token' cannot be empty." >&2
show_help
exit 1
fi
;;
*)
break
;;
Expand All @@ -68,7 +81,18 @@ install_camel_k() {
info=
if [[ "$version" = "latest" ]]
then
install_version=$(curl --silent "https://api.github.com/repos/apache/camel-k/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
#echo "--- $GITHUB_TOKEN ---"
#curl -H "Authorization: $GITHUB_TOKEN" --silent "https://api.github.com/repos/apache/camel-k/releases/latest"
#echo "----"
#curl --silent "https://api.github.com/repos/apache/camel-k/releases/latest"
#curl --silent "https://api.github.com/repos/apache/camel-k/releases/latest" | grep '"tag_name":'
#curl --silent "https://api.github.com/repos/apache/camel-k/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/'
if [[ -z "$github_token" ]]
then
install_version=$(curl --silent "https://api.github.com/repos/apache/camel-k/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
else
install_version=$(curl -H "Authorization: $github_token" --silent "https://api.github.com/repos/apache/camel-k/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
fi
info="=$install_version"
fi
os=$(get_os)
Expand Down
4 changes: 4 additions & 0 deletions main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ main() {
args+=(--version "${INPUT_VERSION}")
fi

if [[ -n "${INPUT_GITHUB_TOKEN:-}" ]]; then
args+=(--github-token "${INPUT_GITHUB_TOKEN}")
fi

if [[ ${#args[@]} -eq 0 ]]
then
"$SCRIPT_DIR/install.sh"
Expand Down

0 comments on commit c7916f8

Please sign in to comment.