From 52535c459bae43087344c2b120e59efe32b1a681 Mon Sep 17 00:00:00 2001 From: nicolaferraro Date: Wed, 14 Jul 2021 11:26:10 +0200 Subject: [PATCH 1/2] Fix CI --- .github/workflows/test.yaml | 22 ++++++++++++++++++++-- action.yml | 2 ++ install.sh | 28 ++++++++++++++++++++++++++-- main.sh | 4 ++++ 4 files changed, 52 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index a70847a..67f781a 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -5,9 +5,25 @@ on: push: branches: - main + schedule: + - cron: "0 7 * * *" 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: @@ -22,6 +38,8 @@ jobs: - name: Install Camel K uses: ./ + with: + github_token: "${{ secrets.GITHUB_TOKEN }}" - name: Test shell: bash @@ -36,8 +54,8 @@ jobs: - macos-latest - windows-latest version: - - v1.2.0 - - v1.1.1 + - v1.5.0 + - v1.4.1 runs-on: ${{ matrix.os }} steps: - name: Checkout diff --git a/action.yml b/action.yml index 462d049..efb7ab3 100644 --- a/action.yml +++ b/action.yml @@ -7,6 +7,8 @@ branding: inputs: version: description: "The Camel K version to use (default: latest)" + github_token: + description: "The Github token used to retrieve latest release from Github" runs: using: "node12" main: "main.js" diff --git a/install.sh b/install.sh index c9155a4..f2e0de9 100755 --- a/install.sh +++ b/install.sh @@ -16,6 +16,8 @@ set -o errexit set -o nounset set -o pipefail +set -x + DEFAULT_VERSION=latest show_help() { @@ -30,7 +32,8 @@ EOF main() { local version="$DEFAULT_VERSION" - + local github_token= + parse_command_line "$@" install_camel_k @@ -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 ;; @@ -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) diff --git a/main.sh b/main.sh index 0fd978e..0d903e6 100755 --- a/main.sh +++ b/main.sh @@ -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" From f4cd37b3fa7195916fb662a46a94d7beb90d2e2e Mon Sep 17 00:00:00 2001 From: nicolaferraro Date: Wed, 14 Jul 2021 11:56:18 +0200 Subject: [PATCH 2/2] Document token --- README.md | 1 + action.yml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ed9b61a..52c5d9a 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/action.yml b/action.yml index efb7ab3..d7cda78 100644 --- a/action.yml +++ b/action.yml @@ -8,7 +8,7 @@ inputs: version: description: "The Camel K version to use (default: latest)" github_token: - description: "The Github token used to retrieve latest release from Github" + description: "Optional token used when fetching the latest Camel K release to avoid hitting rate limits" runs: using: "node12" main: "main.js"