Public composite action: should we call actions/checkout
and actions/setup-java
?
#73309
-
Select Topic AreaQuestion BodyWe developed some public GitHub Actions that allow users to scan their source code. Some of the steps in our composite actions require Java to be available (even if the source code to be scanned is not Java), and obviously we require the source code to be checked out. Does it make sense to call What if the calling workflow does include the
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 3 replies
-
You should design your action to work with a broader range of Java versions, thereby reducing the potential for conflicts. |
Beta Was this translation helpful? Give feedback.
-
Related issue: actions/setup-java#552 which might solve the As a workaround, I guess we could hack...save all the env | grep '^JAVA_HOME_|^PATH' > "${{ runner.temp }}/pre-vars" and then as a cat ${{ runner.temp }}/pre-vars" >> "${GITHUB_ENV}" (totally untested, scripts only for comms.) Re checkout: I would leave that to the user, because you can't know how to clone their repo (submodules, sparse, history, token!, etc.). Considering the age of this, what did you end up doing? |
Beta Was this translation helpful? Give feedback.
-
Another - name: "Execute my Java-requiring thing"
env:
PATH: "${{ env.JAVA_HOME_17_X64 }}/bin:${{ env.PATH }}"
shell: bash
run: java -jar foo.jar Sadly, this does not work however awesome it looks at first sight. In composite actions However, this works: - name: "Execute my Java-requiring thing"
shell: bash
run: |
PATH="${JAVA_HOME_17_X64}/bin:${PATH}"
java -jar foo.jar Note: the author of the composite action is responsible for correct architecture selection! |
Beta Was this translation helpful? Give feedback.
-
@TWiStErRob Maybe it could be of help looking up to the way I did use it at https://github.com/mavenplugins/reusable-gh-actions/blob/master/.github/workflows/__maven_clean_deploy.yml This is:
This was the driver to file PR setup-java#553 Feel free to fork or make use of |
Beta Was this translation helpful? Give feedback.
Related issue: actions/setup-java#552 which might solve the
actions/setup-java
part.As a workaround, I guess we could hack...
save all the
JAVA_HOME*
andPATH
variables to a temp file, something like:and then as a
post:
/last step (if: success() || failure()
): do a(totally untested, scripts only for comms.)
Re checkout: I would leave that to the user, because you can't know how to clone their repo (submodules, sparse, history, token!, etc.).
Considering the age of this, what did you end up doing?