简体   繁体   中英

How to retrieve last uploaded artifact name inside a GitHub Action Tasks?

I am currently working on automating a Java Build and Deployment task where I am using GitHub Actions to perform the Build and Deployment. I am working on snapshots build and the artifact is pushed to JFrog Package Manager and the artifact name looks like jd-bulk-messenger-1.18.0-RC1-SNAPSHOT.war but when it gets pushed to my JFrog Snapshot Repository the same artifact seems to be uploaded with some timestamp as suffix like jd-bulk-messenger-1.18.0-RC1-20220715.124710-5.war .

How to ensure that I deploy the last recent snapshot artifacts on my target servers? I need some way to retrieve the last recent artifact name from JFrog Package Manager.

Note:

  • I know that we can use upload-artifact action to Archive the Artifact and can be used at later jobs with download-artifact action to perform the Deployment.

     name: Archive Build Artifacts uses: actions/upload-artifact@v3
  • But the Artifact size is of around 180 MB, so archiving the artifact of every build seems like not a good idea.

Any suggestions are welcome.

JFrog CLI offers extended support for complex download patterns. I think, following should help you -

First setup JFrog CLI in Github Action, check this link for installation. Once CLI is configured to be used, you use following command to always download the latest snapshot.

jfrog rt dl --flat --limit=1 --sort-by=created --sort-order=desc --url=<ARTIFACTORY_URL> --user=<ARTIFACTORY_USER> --password=<ARTIFACTORY_PW> "<RELATIVE_PATH_TO_ARTIFACTORY_REPO>/jd-bulk-messenger-1.18.0-RC1-*.war"

You can further tune the command according to your need. Check this link to understand more.

Also yes 180MB is big to cache in CI build.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM