TIL = Things, or Today I Learned

An experiment in Learning in Public.


GitHub Actions - how to access GitHub Maven packages via GitHub actions


    <!-- IMPORTANT: id must be the same as in the workflow yml -->
    <name>GitHub Maven Packages</name>
    <!-- NOTE: GH-Enterprise uses prefix https://maven.HOSTNAME/
        e.g., https://maven.github.myawesomeco.com/ 
. . .
  - name: Set up JDK 11
    uses: actions/setup-java@v2
      java-version: '11'
      distribution: 'temurin'
      server-id: github-maven-package

  - name: Print settings xml
    run: |
      $LocalMavenM2Dir = "$env:USERPROFILE\.m2\"
      type $LocalMavenM2Dir\settings.xml

  - name: build and unit test
    run: mvn -B clean test    # pulls in the dependencies
      GITHUB_ACTOR: juliusgb  # can be github org or github username
      # prefer your own instead of secrets.GITHUB_TOKEN (easier to track and can access private repos)

GitHub uses the env variables GITHUB_ACTOR and GITHUB_TOKEN as the default credentials when it generates the settings.xml.

To see what the generated settings.xml looks like is what the step Print settings xml does (on Windows). If you're on Linux, adjust the 2 lines after run: |.