Skip to content

Commit

Permalink
feat: support version and version-file updatecli actions (#181)
Browse files Browse the repository at this point in the history
* feat: support version and version-file updatecli actions

* badge
  • Loading branch information
v1v authored Dec 2, 2024
1 parent 9fe541f commit 4263006
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 13 deletions.
45 changes: 42 additions & 3 deletions .github/workflows/test-updatecli-run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ permissions:
jobs:
test:
needs:
- default
- version
- version-file
- default
- version-file-updatecli
runs-on: ubuntu-latest
steps:
- id: check
Expand All @@ -40,24 +41,62 @@ jobs:
- uses: ./updatecli/run
with:
command: help
- name: Verify updatecli version
run: |
want=$(cat updatecli/install/.default-updatecli-version | cut -dv -f2)
got=$(updatecli version 2>&1)
echo "${got} == ${want}"
[[ "${got}" == *"${want}"* ]]
version:
runs-on: ubuntu-latest
env:
want: "0.86.0"
steps:
- uses: actions/checkout@v4
- uses: ./updatecli/run
with:
command: help
version: v0.86.0
version: "v${{ env.want }}"
- name: Verify updatecli version
run: |
got=$(updatecli version 2>&1)
echo "${got} == ${want}"
[[ "${got}" == *"${want}"* ]]
version-file:
runs-on: ubuntu-latest
env:
want: "0.85.0"
steps:
- uses: actions/checkout@v4
- name: Setup version file
run: |
echo "v0.87.0" > .tools-version
echo "v${want}" > .tools-version
- uses: ./updatecli/run
with:
command: help
version-file: .tools-version
- name: Verify updatecli version
run: |
got=$(updatecli version 2>&1)
echo "${got} == ${want}"
[[ "${got}" == *"${want}"* ]]
version-file-updatecli:
runs-on: ubuntu-latest
env:
want: "0.84.0"
steps:
- uses: actions/checkout@v4
- name: Setup version file
run: |
echo "updatecli v${want}" > .tools-version
- uses: ./updatecli/install
with:
version-file: .tools-version
- name: Verify updatecli version
run: |
got=$(updatecli version 2>&1)
echo "${got} == ${want}"
[[ "${got}" == *"${want}"* ]]
1 change: 1 addition & 0 deletions updatecli/install/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# <!--name-->updatecli/install<!--/name-->

[![usages](https://img.shields.io/badge/usages-white?logo=githubactions&logoColor=blue)](https://github.com/search?q=elastic%2Foblt-actions%2Fupdatecli%2Finstall+%28path%3A.github%2Fworkflows+OR+path%3A**%2Faction.yml+OR+path%3A**%2Faction.yaml%29&type=code)
[![test-updatecli-install](https://github.com/elastic/oblt-actions/actions/workflows/test-updatecli-install.yml/badge.svg?branch=main)](https://github.com/elastic/oblt-actions/actions/workflows/test-updatecli-install.yml)

<!--description-->
This is an opinionated GitHub Action to install the updatecli
Expand Down
16 changes: 9 additions & 7 deletions updatecli/run-and-notify/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ notifications.

## Inputs
<!--inputs-->
| Name | Description | Required | Default |
|--------------------|-----------------------------------------------------|----------|-----------|
| `command` | Specify the updatecli command to be executed. | `true` | ` ` |
| `slack-channel-id` | | `true` | ` ` |
| `slack-bot-token` | Specify the slack bot token. | `true` | ` ` |
| `slack-message` | Specify the message to be sent (markdown format). | `true` | ` ` |
| `slack-send-when` | When to send the message, always, failure, success. | `false` | `failure` |
| Name | Description | Required | Default |
|--------------------|---------------------------------------------------------------------------------------------------------------------|----------|-----------|
| `command` | Specify the updatecli command to be executed. | `true` | ` ` |
| `slack-channel-id` | | `true` | ` ` |
| `slack-bot-token` | Specify the slack bot token. | `true` | ` ` |
| `slack-message` | Specify the message to be sent (markdown format). | `true` | ` ` |
| `slack-send-when` | When to send the message, always, failure, success. | `false` | `failure` |
| `version` | Install a specific version of updatecli. If both `version` and `version-file` are provided, `version` will be used. | `false` | ` ` |
| `version-file` | The file to read the version from. E.g. `.updatecli-version` or `.tool-versions` (asdf-vm). | `false` | ` ` |
<!--/inputs-->

## Usage
Expand Down
8 changes: 8 additions & 0 deletions updatecli/run-and-notify/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,20 @@ inputs:
description: 'When to send the message, always, failure, success.'
default: 'failure'
required: false
version:
description: "Install a specific version of updatecli. If both `version` and `version-file` are provided, `version` will be used."
required: false
version-file:
description: "The file to read the version from. E.g. `.updatecli-version` or `.tool-versions` (asdf-vm)."
required: false
runs:
using: composite
steps:
- uses: elastic/oblt-actions/updatecli/run@v1
with:
command: ${{ inputs.command }}
version: "${{ inputs.version }}"
version-file: "${{ inputs.version-file }}"

- if: ${{ always() && inputs.slack-send-when == 'always' }}
uses: elastic/oblt-actions/slack/send@v1
Expand Down
9 changes: 6 additions & 3 deletions updatecli/run/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
# <!--name-->updatecli/run<!--/name-->

[![usages](https://img.shields.io/badge/usages-white?logo=githubactions&logoColor=blue)](https://github.com/search?q=elastic%2Foblt-actions%2Fupdatecli%2Frun+%28path%3A.github%2Fworkflows+OR+path%3A**%2Faction.yml+OR+path%3A**%2Faction.yaml%29&type=code)
[![test-updatecli-run](https://github.com/elastic/oblt-actions/actions/workflows/test-updatecli-run.yml/badge.svg?branch=main)](https://github.com/elastic/oblt-actions/actions/workflows/test-updatecli-run.yml)

## Inputs

<!--inputs-->
| Name | Description | Required | Default |
|-----------|-----------------------------------------------|----------|---------|
| `command` | Specify the updatecli command to be executed. | `true` | ` ` |
| Name | Description | Required | Default |
|----------------|---------------------------------------------------------------------------------------------------------------------|----------|---------|
| `command` | Specify the updatecli command to be executed. | `true` | ` ` |
| `version` | Install a specific version of updatecli. If both `version` and `version-file` are provided, `version` will be used. | `false` | ` ` |
| `version-file` | The file to read the version from. E.g. `.updatecli-version` or `.tool-versions` (asdf-vm). | `false` | ` ` |
<!--/inputs-->

## Usage
Expand Down
9 changes: 9 additions & 0 deletions updatecli/run/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,19 @@ inputs:
command:
description: 'Specify the updatecli command to be executed.'
required: true
version:
description: "Install a specific version of updatecli. If both `version` and `version-file` are provided, `version` will be used."
required: false
version-file:
description: "The file to read the version from. E.g. `.updatecli-version` or `.tool-versions` (asdf-vm)."
required: false
runs:
using: composite
steps:
- uses: elastic/oblt-actions/updatecli/install@v1
with:
version: "${{ inputs.version }}"
version-file: "${{ inputs.version-file }}"

- run: updatecli ${{ env.COMMAND }}
env:
Expand Down

0 comments on commit 4263006

Please sign in to comment.