How to deploy a module snapshot to JFrog Artifactory using Github actions?

Hi folks,

I have a requirement where I need to deploy a module snapshot to JFrog Artifactory using Github actions. I am not familiar with how the job to deploy would exactly be however, have written this

publish:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2

      - name: Set up JDK 1.8
        uses: actions/setup-java@v1
        with:
          java-version: 1.8

      - name: Build with Maven
        run: mvn clean package

      - name: Publish to JFrog Artifactory
        run: mvn deploy
        env:
          registry: <jfrog artifactory url>
          username: ${{ secrets.JFROG_USERNAME }}
          password: ${{ secrets.JFROG_PASSWORD }}
          GITHUB_TOKEN: "${{ secrets.REPOSITORY_TOKEN }}"

and set JFROG_USERNAME, JFROG_PASSWORD and REPOSITORY_TOKEN as secretes in the repository settings.

When I run the job I get an error:

Failed to deploy artifacts: Could not transfer artifact

authentication failed 401 Unauthorized

Note that am able to use these credentials to login into JFrog account and able to deploy the snapshot manually.

Thanks.

Is this for OpenMRS’s Artifactory instance or something else? Because currently the general policy is that things should be deployed to OpenMRS’s Artifactory instance via Bamboo and not GitHub Actions. If there’s a specific case (and we have one or two) we should talk about how to make that work.

That said, you should definitely look at the setup-java's documentation on how to publish using Maven and ensure that the “password” is actually a JFrog API key.

Yes!

If there’s a specific case (and we have one or two) we should talk about how to make that work.

Following up the post I made here and my response to your comment, I wanted to implement the idea to aid in testing out the effect of the proposed changes in the PRs on a staging environment before actually being merged.