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

Add the ability to install only particular tools #401

Open
ibratoev opened this issue Jan 9, 2022 · 1 comment
Open

Add the ability to install only particular tools #401

ibratoev opened this issue Jan 9, 2022 · 1 comment

Comments

@ibratoev
Copy link

ibratoev commented Jan 9, 2022

Currently, the install command installs all the tools defined in .tool-versions.
In certain CI workflows, you may need only a subset of the tools. Allow installing only the specified tools.

@jonath92
Copy link

jonath92 commented Nov 18, 2023

I am also looking forward to this. As a workaround I have created the following custom action, which installs and caches a single asdf plugin.

name: "Install asdf"
description: "Installs asdf"

inputs:
  plugin:
    description: "The asdf plugin to install. Must be set in ./.tool-versions"
    required: true

runs:
  using: "composite"
  steps:
    - name: Determine plugin version
      shell: bash
      id: determine_version
      run: echo "version=$(grep '^${{ inputs.plugin }}' ./.tool-versions | awk '{print $2}')" >> $GITHUB_OUTPUT

    - name: cache asdf
      id: cache-asdf
      uses: actions/cache@v3
      with:
        path: ~/.asdf
        key: ${{ runner.os }}-asdf-${{ inputs.plugin }}-${{ steps.determine_version.outputs.version }}

    - name: setup asdf
      if: steps.cache-asdf.outputs.cache-hit != 'true'
      uses: asdf-vm/actions/setup@v2

    - name: Install asdf plugin
      shell: bash
      if: steps.cache-asdf.outputs.cache-hit != 'true'
      run: |
        asdf plugin add ${{ inputs.plugin }}
        asdf install ${{ inputs.plugin }} ${{ steps.determine_version.outputs.version }}

You can test use it inside your workflow by:

name: build
on:
  push:
    branches: main

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4
      - name: Cache and install java
        uses: ./.github/actions/install-and-cache-asdf-plugins
        with:
          plugin: java

With the following directory structure:

├── .github
│   ├── actions
│   │   └── install-and-cache-asdf-plugins
│   │       └── action.yml
│   └── workflows
│       └── build.yml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants