Skip to content

Choose one randomly from multiple user inputs

License

Notifications You must be signed in to change notification settings

ddradar/choose-random-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

Choose Random Action

last commit release version Node.js CI/CD codecov CodeFactor License

日本語版のガイドはこちらです。

Choose one randomly from multiple user inputs

TOC

Usage

Basic

steps:
  - uses: ddradar/choose-random-action@v3.0.0
    id: act # required to reference output
    with:
      contents: |
        foo
        bar
        baz
      weights: |
        2
        3
        5
  - name: Echo outputs
    run: echo ${{ steps.act.outputs.selected }} # foo: 20%, bar: 30%, baz: 50%
name: Send LGTM Image
on:
  issue_comment:
    types: [created]
  pull_request_review:
    types: [submitted]
jobs:
  post:
    runs-on: ubuntu-latest
    if: (!contains(github.actor, '[bot]')) # Exclude bot comment
    steps:
      - uses: ddradar/choose-random-action@v3.0.0
        id: act
        with:
          contents: |
            https://example.com/your-lgtm-image-1.jpg
            https://example.com/your-lgtm-image-2.jpg
            https://example.com/your-lgtm-image-3.jpg
      - uses: ddradar/lgtm-action@v3
        with:
          image-url: ${{ steps.act.outputs.selected }}

Options

contents

Required.

String choices you want to choose randomly.

weights

Optional.

Set natural integer if you want to weight the choices. Make it the same length as the contents. By default, all content has equal weight.

License

MIT License

Contributing

See guide.