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

Inputs are ignored #38

Closed
DavidJFowler opened this issue Nov 22, 2023 · 2 comments · Fixed by #14
Closed

Inputs are ignored #38

DavidJFowler opened this issue Nov 22, 2023 · 2 comments · Fixed by #14

Comments

@DavidJFowler
Copy link

All the actions specify inputs, e.g. record-deployment/action.yml:

name: "record-deployment"
description: "Record deployment of an application to an environment"
branding:
  icon: "check"
  color: "green"
inputs:
  PACT_BROKER_BASE_URL:
    description: "The url of your pact broker"
    required: true
  PACT_BROKER_TOKEN:
    description: "Your pact broker token"
    required: true
  application_name:
    description: "The name of your application (usually project name)"
    required: true
  version:
    description: "The version of your application (defaults to latest)"
    required: true
runs:
  using: "composite"
  steps:
    - run: ${{ github.action_path }}/recordDeployment.sh
      shell: bash

However, in the bash scripts, the inputs are ignored and the values of environment variables are used.

@YOU54F
Copy link
Member

YOU54F commented Jan 18, 2024

you are correct, they aren't used as you have to map with (input) & env vars. we currently only support env vars, which can be set either at a top level of a workflow, or at an individual action level if you want different values.

If this is an issue, we would be happy to accept a PR that can deal with both, we would just need to make a decision as to which takes precedence if both are specified (workflow input vs env var), pick one and warn the user.

Or potentially have an option to fail fast, if multiple options are specified so the user has an opt-in chance to rectify

@twalshOG
Copy link

twalshOG commented Sep 9, 2024

@YOU54F
This is extremely unintuitive.
The action says some parameters are required, but they aren't.
Even if you add them, they are 100% ignored.

Examples of why this is so unintuitive

Work, but parser gives me the following error
Missing required inputs: PACT_BROKER_BASE_URL, PACT_BROKER_TOKEN, application_name, to

      - uses: pactflow/actions/can-i-deploy@v1.3.0
        env:
          to: development
          version: ${{ env.VERSION }}
          application_name: "NAME"
          PACT_BROKER_BASE_URL: ${{ secrets.PACT_BROKER_BASE_URL }}
          PACT_BROKER_TOKEN: ${{ secrets.PACT_BROKER_TOKEN }}

Works, but with parameters are ignored

      - uses: pactflow/actions/can-i-deploy@v1.3.0
        with:
          PACT_BROKER_BASE_URL: Anything
          PACT_BROKER_TOKEN: Anything 
          application_name: Anything
          version: Anything
          to: Anything
        env:
          to: development
          version: ${{ env.VERSION }}
          application_name: "NAME"
          PACT_BROKER_BASE_URL: ${{ secrets.PACT_BROKER_BASE_URL }}
          PACT_BROKER_TOKEN: ${{ secrets.PACT_BROKER_TOKEN }}

Fails, but the parser is happy
This should be what actually works!

      - uses: pactflow/actions/can-i-deploy@v1.3.0
        with:
          to: development
          version: ${{ env.VERSION }}
          application_name: "NAME"
          PACT_BROKER_BASE_URL: ${{ secrets.PACT_BROKER_BASE_URL }}
          PACT_BROKER_TOKEN: ${{ secrets.PACT_BROKER_TOKEN }}

Recommendation

Instead of this

runs:
  using: "composite"
  steps:
    - run: ${{ github.action_path }}/canideployTo.sh
      shell: bash

Do this:
*Works without a version break

runs:
  using: "composite"
  steps:
    - run: ${{ github.action_path }}/canideployTo.sh
      shell: bash
      env:
        PACT_BROKER_TOKEN: ${{ inputs.PACT_BROKER_TOKEN || env.PACT_BROKER_TOKEN }}
        PACT_BROKER_BASE_URL: ${{ inputs.PACT_BROKER_BASE_URL || env.PACT_BROKER_BASE_URL }}
        application_name: ${{ inputs.application_name || env.application_name }}
        version: ${{ inputs.version || env.version }}
        latest: ${{ inputs.latest || env.latest }}
        to: ${{ inputs.to || env.to }}
        retry_while_unknown: ${{ inputs.retry_while_unknown || env.retry_while_unknown }}
        retry_interval: ${{ inputs.retry_interval || env.retry_interval }}

Or this:
*Works but should be a major version (v1 -> v2) break

runs:
  using: "composite"
  steps:
    - run: ${{ github.action_path }}/canideployTo.sh
      shell: bash
      env:
        PACT_BROKER_TOKEN: ${{ inputs.PACT_BROKER_TOKEN }}
        PACT_BROKER_BASE_URL: ${{ inputs.PACT_BROKER_BASE_URL }}
        application_name: ${{ inputs.application_name }}
        version: ${{ inputs.version }}
        latest: ${{ inputs.latest }}
        to: ${{ inputs.to }}
        retry_while_unknown: ${{ inputs.retry_while_unknown }}
        retry_interval: ${{ inputs.retry_interval }}

YOU54F added a commit that referenced this issue Sep 13, 2024
- ⚠️ Migrates to workflow-inputs over environment variables. Fixes #38
  - Users should see the actions.yml in each action, for correct usage
  - Will require users to switch from `env:` to `with:`, however existing environment variables will be picked up.
- ⚠️ inputs for `publish-provider-contract` have changed, see actions file `./publish-pact-files/action.yml`, existing values will be picked up
- adds command
  -  record-release
- supports auto-detection of version in
  - record-release
  - record-deployment
  - publish-provider-contract (including branch)
  - publish-pact-files (including branch)
  - create-version-tag
  - create-or-update-version (including branch)
  - can-i-deploy
- Support for Pact Broker Basic Auth via `PACT_BROKER_USERNAME` / `PACT_BROKER_PASSWORD`

Will be bumped to V2, so it is opt-in unless users are running against main
@YOU54F YOU54F closed this as completed in 24c62d2 Sep 13, 2024
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

Successfully merging a pull request may close this issue.

3 participants