setup-java icon indicating copy to clipboard operation
setup-java copied to clipboard

Fixes #85. Add support for multiple server ids.

Open drewctaylor opened this issue 5 years ago • 3 comments

This PR does not fully address #85; it does not allow the user to specify a list of servers as follows:

server-list:
  - server-id: value-of-server-id-1
    server-username: SERVER_USERNAME_1
    server-password: SERVER_PASSWORD_1
  - server-id: value-of-server-id-2
    server-username: SERVER_USERNAME_2
    server-password: SERVER_PASSWORD_2

As GitHub Actions do not appear to support YAML parameters.

However, it does allow the user to specify a list of server ids as follows:

- name: Step 2 - Setup Java.
  uses: drewctaylor/setup-java@actions-setup-java-85-b
  with:
    java-version: 11
    server-id-list: require, type-encoded, github
    server-username: SERVER_USERNAME
    server-password: SERVER_PASSWORD

- name: Step 3 - Maven Deploy.
  run: mvn -B deploy
  env:
    SERVER_USERNAME: ${{ github.actor }}
    SERVER_PASSWORD: ${{ github.token }}

Which produces a settings xml as follows:

<server>
  <id>github</id>
  <username>value-of-server-username</username>
  <password>value-of-server-password</password>
</server>
<server>
  <id>require</id>
  <username>value-of-server-username</username>
  <password>value-of-server-password</password>
</server>
<server>
  <id>type-encoded</id>
  <username>value-of-server-username</username>
  <password>value-of-server-password</password>
</server>

In general, the action concatenates the value of server-id to the value of server-id-list, removes any duplicates, and produces one server entry per value.

For example,

  • if the client specifies neither server-id nor server-id-list, the action concatenates the default value of server-id (github) to the default value of server-id-list ([github]), producing ([github, github]); the action then removes the duplicate github and produces one server entry for the remaining github.
  • if the client specifies server-id but not server-id-list, the action concatenates the value of server-id (say, server) and the default value of server-id-list ([github]), producing ([github, server]); the action then produces two server entries, one for github and one for server.
  • similarly, if the client specifies server-id-list but not server-id, the action concatenates the default value of server-id (github) to the value of server-id-list (say, [server1, server2]), producing ([github, server1, server2]); the action then produces three server entries, one for github, one for server1, and one for server2.

A successful run of this PR is here:

https://github.com/drewctaylor/constrain/actions/runs/191542087/workflow

drewctaylor avatar Aug 01 '20 21:08 drewctaylor

I would be interested in seeing this merged, or better yet a full fix for #85

Out of interest, is there any reason you chose to switch to server-id-list over the full fix of server-list?

GavinF17 avatar Oct 13 '20 15:10 GavinF17

@GavinF17 - I switched from server-list to server-id-list because it doesn't appear to be possible to receive values (such as server-list) as anything but strings. If it were possible to receive the value of server-list as, say, a JSON structure, I would have implemented the full fix.

drewctaylor avatar Oct 27 '20 15:10 drewctaylor

@thboop @chrispat @tbroyer Can we think about merging this. We need this feature for our org and it would be very useful for many people.

rachit-rw avatar Nov 06 '20 09:11 rachit-rw