Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert to composite action and use cache dir #55

Merged
merged 1 commit into from
Nov 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ A GitHub action to turn a GitHub project into a self-hosted Helm chart repo, usi

For more information on inputs, see the [API Documentation](https://developer.github.com/v3/repos/releases/#input)

- `version`: The chart-releaser version to use (default: v1.0.0)
- `version`: The chart-releaser version to use (default: v1.1.1)
- `config`: Optional config file for chart-releaser
- `charts_dir`: The charts directory
- `charts_repo_url`: The GitHub Pages URL to the charts repo (default: `https://<owner>.github.io/<project>`)
Expand Down Expand Up @@ -46,8 +46,13 @@ jobs:
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"

- name: Install Helm
uses: azure/setup-helm@v1
with:
version: v3.4.0

- name: Run chart-releaser
uses: helm/chart-releaser-action@v1.0.0
uses: helm/chart-releaser-action@v1.1.1
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
```
Expand Down
28 changes: 24 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,35 @@ branding:
icon: anchor
inputs:
version:
description: "The chart-releaser version to use (default: v1.0.0)"
description: "The chart-releaser version to use (default: v1.1.1)"
config:
description: "The relative path to the chart-releaser config file"
charts_dir:
description: The charts directory
default: charts
charts_repo_url:
description: "The GitHub Pages URL to the charts repo (default: https://<owner>.github.io/<repo>)"
required: true
runs:
using: "node12"
main: "main.js"
using: composite
steps:
- run: |
owner=$(cut -d '/' -f 1 <<< "$GITHUB_REPOSITORY")
repo=$(cut -d '/' -f 2 <<< "$GITHUB_REPOSITORY")

args=(--owner "$owner" --repo "$repo")
args+=(--charts-dir "${{ inputs.charts_dir }}")

if [[ -n "${{ inputs.version }}" ]]; then
args+=(--version "${{ inputs.version }}")
fi

if [[ -n "${{ inputs.config }}" ]]; then
args+=(--config "${{ inputs.config }}")
fi

if [[ -n "${{ inputs.charts_repo_url }}" ]]; then
args+=(--charts-repo-url "${{ inputs.charts_repo_url }}")
fi

"$GITHUB_ACTION_PATH/cr.sh" "${args[@]}"
shell: bash
27 changes: 21 additions & 6 deletions cr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ set -o errexit
set -o nounset
set -o pipefail

DEFAULT_CHART_RELEASER_VERSION=v1.1.0
DEFAULT_CHART_RELEASER_VERSION=v1.1.1

show_help() {
cat << EOF
Expand Down Expand Up @@ -177,11 +177,26 @@ parse_command_line() {
}

install_chart_releaser() {
echo "Installing chart-releaser..."
if [[ ! -d "$RUNNER_TOOL_CACHE" ]]; then
echo "Cache directory '$RUNNER_TOOL_CACHE' does not exist" >&2
exit 1
fi

local arch
arch=$(uname -m)

curl -sSLo cr.tar.gz "https://github.com/helm/chart-releaser/releases/download/$version/chart-releaser_${version#v}_linux_amd64.tar.gz"
tar -xzf cr.tar.gz
sudo mv cr /usr/local/bin/cr
local cache_dir="$RUNNER_TOOL_CACHE/ct/$version/$arch"
if [[ ! -d "$cache_dir" ]]; then
mkdir -p "$cache_dir"

echo "Installing chart-releaser..."
curl -sSLo cr.tar.gz "https://github.com/helm/chart-releaser/releases/download/$version/chart-releaser_${version#v}_linux_amd64.tar.gz"
tar -xzf cr.tar.gz -C "$cache_dir"
rm -f cr.tar.gz

echo 'Adding cr directory to PATH...'
export PATH="$cache_dir:$PATH"
fi
}

lookup_latest_tag() {
Expand Down Expand Up @@ -219,7 +234,7 @@ lookup_changed_charts() {
package_chart() {
local chart="$1"

local args=(--package-path .cr-release-packages)
local args=("$chart" --package-path .cr-release-packages)
if [[ -n "$config" ]]; then
args+=(--config "$config")
fi
Expand Down
19 changes: 0 additions & 19 deletions main.js

This file was deleted.

45 changes: 0 additions & 45 deletions main.sh

This file was deleted.