Skip to content

Commit

Permalink
Setup ecm-distro-tools GitHub Action (#267)
Browse files Browse the repository at this point in the history
Signed-off-by: Brooks Newberry <[email protected]>
  • Loading branch information
brooksn authored Oct 5, 2023
1 parent c36bafa commit 60e9529
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,30 @@ docker run --rm -it --env GITHUB_TOKEN=<TOKEN> rancher/ecm-distro-tools tag_rke2

See seperate [documentation](./docs/test_pad.md) for test-pad tool.

## GitHub action

This repository provides the "Setup ecm-distro-tools" GitHub action.
It downloads the assets belonging to the specified release to a temporary directory,
and adds the directory to the `PATH`.

### Usage

The action can be run on ubuntu-latest runners.
The `version` parameter is required.
Providing the GH_TOKEN environment variable is recommended to avoid rate limiting by the GitHub API.

```yaml
steps:
- name: setup ecm-distro-tools
uses: rancher/ecm-distro-tools
with:
version: v0.23.0
env:
GH_TOKEN: ${{ github.token }}
- name: release notes
run: gen_release_notes -h
```
## Contributing
We welcome additions to this repo and are excited to keep expanding its functionality.
Expand Down
34 changes: 34 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: 'Setup ecm-distro-tools'
description: 'Installs ecm-distro-tools scripts to the PATH.'
inputs:
version:
description: 'The tag of the ecm-distro-tools release to install.'
required: true
runs:
using: 'composite'
steps:
- shell: bash
run: |
TAG="${{ inputs.version }}"
REPO="rancher/ecm-distro-tools"
DOWNLOAD_DIR="$RUNNER_TEMP/ecm-distro-tools"
mkdir -p "$DOWNLOAD_DIR"
echo "$DOWNLOAD_DIR" >> "$GITHUB_PATH"
GH_AUTHENTICATED=$(gh auth status >/dev/null 2>&1; echo $?)
if [ "$GH_AUTHENTICATED" -eq 0 ]; then
echo "is authenticated"
gh release download "$TAG" --repo "$REPO" --dir "$DOWNLOAD_DIR"
else
echo "not authenticated"
URLS=$(curl -s "https://api.github.com/repos/$REPO/releases/tags/$TAG" \
| jq -r '.assets[] | .browser_download_url')
echo "$URLS" | while read -r url; do
FILENAME=$(basename "$url")
curl -sS -L "$url" -o "$DOWNLOAD_DIR/$FILENAME"
done
fi
chmod +x "$DOWNLOAD_DIR/"*
ls -al "$DOWNLOAD_DIR"

0 comments on commit 60e9529

Please sign in to comment.