-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from colearendt/improve-ci
Improve ci
- Loading branch information
Showing
6 changed files
with
234 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: Document Charts | ||
|
||
on: | ||
pull_request: | ||
|
||
jobs: | ||
document: | ||
runs-on: ubuntu-latest | ||
name: helm-docs | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- uses: r-lib/actions/pr-fetch@master | ||
with: | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Set up Helm | ||
uses: azure/setup-helm@v1 | ||
with: | ||
version: v3.6.3 | ||
|
||
- name: Install helm-docs | ||
env: | ||
version: 1.5.0 | ||
run: | | ||
echo "Installing helm-docs version $version" | ||
curl -L -o helm-docs.tar.gz https://github.com/norwoodj/helm-docs/releases/download/v${version}/helm-docs_${version}_Linux_x86_64.tar.gz | ||
tar -xzvf helm-docs.tar.gz helm-docs | ||
rm -rf helm-docs.tar.gz | ||
- name: Run helm-docs | ||
run: | | ||
./helm-docs --chart-search-root=charts --template-files=README.md.gotmpl --template-files=./_templates.gotmpl | ||
- name: Commit results | ||
run: | | ||
set -xe | ||
git config --local user.email "[email protected]" | ||
git config --local user.name "GitHub Actions" | ||
git commit charts/*/README.md -m 'Update helm-docs and README.md' || echo "No changes to commit" | ||
- uses: r-lib/actions/pr-push@master | ||
with: | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
name: Rebuild index.yaml manually | ||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
rebuild: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
ref: 'gh-pages' | ||
fetch-depth: 0 | ||
|
||
- name: Set up Helm | ||
uses: azure/setup-helm@v1 | ||
with: | ||
version: v3.6.3 | ||
|
||
- name: Rebuild index.yaml | ||
env: | ||
version: v1.2.1 | ||
run: | | ||
if [[ ! -d "$RUNNER_TOOL_CACHE" ]]; then | ||
echo "Cache directory '$RUNNER_TOOL_CACHE' does not exist" >&2 | ||
exit 1 | ||
fi | ||
arch=$(uname -m) | ||
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 | ||
echo "Rebuilding index.yaml" | ||
scripts/rebuild.sh | ||
- name: Create Pull Request | ||
id: cpr | ||
uses: peter-evans/create-pull-request@v3 | ||
with: | ||
commit-message: Rebuild index.yaml | ||
title: Rebuild index.yaml | ||
|
||
- name: Check outputs | ||
run: | | ||
echo "Created Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" | ||
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,9 +24,11 @@ jobs: | |
- name: Install Helm | ||
uses: azure/setup-helm@v1 | ||
with: | ||
version: v3.4.0 | ||
version: v3.6.3 | ||
|
||
- name: Run chart-releaser | ||
uses: helm/[email protected] | ||
uses: helm/[email protected] | ||
with: | ||
charts_repo_url: https://colearendt.github.io/helm/ | ||
env: | ||
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,15 @@ | ||
name: Lint and Test Charts | ||
|
||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
- main | ||
pull_request: | ||
branches: | ||
- master | ||
- main | ||
|
||
jobs: | ||
lint-test: | ||
runs-on: [ubuntu-latest] | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
@@ -24,7 +20,7 @@ jobs: | |
- name: Set up Helm | ||
uses: azure/setup-helm@v1 | ||
with: | ||
version: v3.4.0 | ||
version: v3.6.3 | ||
|
||
- name: Set up helm repos | ||
run: | | ||
|
@@ -35,21 +31,50 @@ jobs: | |
python-version: 3.7 | ||
|
||
- name: Set up chart-testing | ||
uses: helm/chart-testing-action@v2.0.1 | ||
uses: helm/chart-testing-action@v2.1.0 | ||
|
||
- name: Run chart-testing (list-changed) | ||
id: list-changed | ||
run: | | ||
changed=$(ct list-changed) | ||
changed=$(ct list-changed --target-branch main) | ||
if [[ -n "$changed" ]]; then | ||
echo "::set-output name=changed::true" | ||
fi | ||
- name: Run chart-testing (lint) | ||
run: ct lint | ||
- name: Run chart-testing (lint changed) | ||
run: ct lint --target-branch main | ||
|
||
- name: Run chart-testing (lint all) | ||
run: ct lint --target-branch main --all | ||
|
||
install: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up Helm | ||
uses: azure/setup-helm@v1 | ||
with: | ||
version: v3.6.3 | ||
|
||
- uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.7 | ||
|
||
- name: Set up chart-testing | ||
uses: helm/[email protected] | ||
|
||
- name: Run chart-testing (list-changed) | ||
id: list-changed | ||
run: | | ||
changed=$(ct list-changed --target-branch main) | ||
if [[ -n "$changed" ]]; then | ||
echo "::set-output name=changed::true" | ||
fi | ||
- name: Run chart-testing (lint --all) | ||
run: ct lint --all | ||
- name: Install kubectl | ||
uses: azure/setup-kubectl@v1 | ||
|
@@ -63,7 +88,16 @@ jobs: | |
|
||
#- name: Create kind cluster | ||
# uses: helm/[email protected] | ||
# if: steps.list-changed.outputs.changed == 'true' | ||
# if: ( steps.list-changed.outputs.changed == 'true' ) || ${{ github.ref == 'refs/heads/main' }} | ||
|
||
# no allow-failure until https://github.com/actions/toolkit/issues/399 | ||
- name: Run chart-testing (install changed) | ||
if: ${{ github.ref != 'refs/heads/main' }} | ||
run: ct install --target-branch main | ||
continue-on-error: true | ||
|
||
- name: Run chart-testing (install) | ||
run: ct install | ||
# no allow-failure until https://github.com/actions/toolkit/issues/399 | ||
- name: Run chart-testing (install all) | ||
if: ${{ github.ref == 'refs/heads/main' }} | ||
run: ct install --target-branch main --all | ||
continue-on-error: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Rebuilding Index | ||
|
||
The Helm `index.yaml` is hosted on the `gh-pages` branch of this repo. If this | ||
index becomes out-of-sync with the releases, you can rebuild it by using a | ||
GitHub Actions Workflow. | ||
|
||
## Prerequisites | ||
|
||
- To use the `rebuild.sh` script with our workflow, the `rebuild.sh` | ||
script must be checked in to the `gh-pages` branch. If you make any changes | ||
to the script in this directory, make sure you also commit the same changes | ||
to the `gh-pages` branch. | ||
- You must have permission to run GitHub Actions Workflows for this repo. | ||
|
||
## Running the Action | ||
|
||
- Navigate to | ||
https://github.com/colearendt/helm/actions/workflows/chart-rebuild.yaml. | ||
- Use the `Run Workflow` button to run the workflow. | ||
- Review the Pull Request created by the workflow. | ||
- When approved, merge the Pull Request into the `gh-pages` branch. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Run this script from the root of the helm repo, e.g., | ||
# ./scripts/rebuild.sh. You must have curl and cr installed. See | ||
# https://github.com/helm/chart-releaser#installation. | ||
|
||
# Set this to a valid URL *without* an index.yaml if you want to regenerate | ||
# a new index.html. If you want to append to an existing one, you can | ||
# use a real address like `https://helm.rstudio.com`. If an existing | ||
# index.yaml is found at this URL, then any packages we generate will | ||
# be appended, which can result in duplicates. | ||
HELM_REPO=${HELM_REPO:-https://rstudio.com} | ||
|
||
# Create a temporary directory and clean it up when we're done. | ||
TMP_DIR=$(mktemp -d) | ||
function cleanup() | ||
{ | ||
echo "Removing temporary directory ${TMP_DIR}." | ||
rm -rf $TMP_DIR | ||
} | ||
trap cleanup EXIT | ||
|
||
# Optional variables you can define in your env | ||
PACKAGE_DIR=${PACKAGE_DIR:-${TMP_DIR}} | ||
CHARTS_DIR=${CHARTS_DIR:-charts} | ||
INDEX=${INDEX:-index.yaml} | ||
GITHUB_OWNER=${GITHUB_OWNER:-rstudio} | ||
GITHUB_REPO=${GITHUB_REPO:-helm} | ||
|
||
# Calculated variables | ||
DOWNLOADS_BASE="https://github.com/${GITHUB_OWNER}/${GITHUB_REPO}/releases/download" | ||
|
||
# List all tags oldest to newest, followed by the 'main' branch. | ||
tags="$(git tag -l --sort=creatordate) main" | ||
|
||
# Clean the packages release directory that `cr` uses. | ||
mkdir -p ${PACKAGE_DIR} | ||
rm -rf ${PACKAGE_DIR}/* | ||
|
||
# Download existing assets from Github | ||
for tag in $tags; do | ||
dl_url="${DOWNLOADS_BASE}/${tag}/${tag}.tgz" | ||
cd ${PACKAGE_DIR} | ||
curl -LOs --fail ${dl_url} | ||
result=$? | ||
if [[ ${result} -eq 0 ]]; then | ||
echo "Downloaded $dl_url". | ||
else | ||
echo "Could not download $dl_url". | ||
fi | ||
cd - | ||
done | ||
|
||
echo "Writing index to ${INDEX}" | ||
rm ${INDEX} | ||
cr index --owner ${GITHUB_OWNER} --git-repo ${GITHUB_REPO} --charts-repo ${HELM_REPO} -p ${PACKAGE_DIR} -i ${INDEX} |