Skip to content

Commit

Permalink
new: Add upgrade option (#7)
Browse files Browse the repository at this point in the history
* Add upgrade option

* default to true

* update test case

* ternary hack

* Compute args separately
  • Loading branch information
lgarber-akamai authored Oct 12, 2023
1 parent e3af3fb commit a7837d4
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 9 deletions.
16 changes: 15 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,18 @@ jobs:
- name: Assert optional dep installed
run: pip freeze | grep -q boto3
- name: Run an authenticated command
run: linode-cli linodes ls > /dev/null
run: linode-cli linodes ls > /dev/null

test-no-upgrade:
runs-on: ubuntu-latest
name: Test the action with upgrade disabled
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install the Linode CLI
uses: ./
with:
token: "${{ secrets.LINODE_TOKEN }}"
upgrade: false
- name: Run an authenticated command
run: linode-cli linodes ls > /dev/null
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ This GitHub Action is designed to run on Ubuntu-based runners and may not functi

This GitHub Action exposes the following arguments:

| Name | Required | Default | Description |
|----------------|----------|---------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `token` | No | None | The [Linode Personal Access Token](https://www.linode.com/docs/products/tools/api/guides/manage-api-tokens/) to authenticate the CLI with. |
| `version` | No | latest | The version of the Linode CLI to install. |
| `setup-python` | No | true | If true, Python will automatically be installed on the runner. If false, users are expected to have a functioning Python installation on their runner before running this action. |
| Name | Required | Default | Description |
|-----------------|----------|---------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `token` | No | None | The [Linode Personal Access Token](https://www.linode.com/docs/products/tools/api/guides/manage-api-tokens/) to authenticate the CLI with. |
| `version` | No | latest | The version of the Linode CLI to install. |
| `setup-python` | No | true | If true, Python will automatically be installed on the runner. If false, users are expected to have a functioning Python installation on their runner before running this action. |
| `upgrade` | No | true | If true, Linode CLI and its dependencies will be automatically upgraded. (--upgrade) |

## Getting Started

Expand Down
21 changes: 18 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ inputs:
setup-python:
description: 'If true, Python will automatically be installed on the runner.'
default: true
upgrade:
description: 'If true, Linode CLI and its dependencies will be automatically upgraded. (--upgrade)'
default: true
runs:
using: 'composite'
steps:
Expand All @@ -29,10 +32,11 @@ runs:
with:
python-version: '3.x'

- name: Determine CLI install extension
id: determine_install_ext
- name: Determine CLI install arguments
id: determine_install_args
shell: bash
run: |
# Compute extension
EXTENSION=""
if [ "$OPTIONAL_DEPS" == "true" ]
Expand All @@ -46,12 +50,23 @@ runs:
fi
echo "version_extension=${EXTENSION}" >> $GITHUB_ENV
# Compute args
ARGS=""
if [ "$UPGRADE" == "true" ]
then
ARGS="${ARGS}--upgrade "
fi
echo "pip_args=${ARGS}" >> $GITHUB_ENV
env:
VERSION: ${{ inputs.version }}
OPTIONAL_DEPS: ${{ inputs.optional-deps }}
UPGRADE: ${{ inputs.upgrade }}

- name: Install the Linode CLI
run: pip3 install linode-cli${{ env.version_extension }}
run: pip3 install ${{ env.pip_args }}linode-cli${{ env.version_extension }}
shell: bash

- name: Expose the Linode Token to the runner environment
Expand Down

0 comments on commit a7837d4

Please sign in to comment.