Home GitHub Actions - how to access GitHub Maven packages via GitHub actions
Post
Cancel

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

Steps:

1
2
3
4
5
6
7
8
9
10
...
  <repository>
    <!-- IMPORTANT: id must be the same as in the workflow yml -->
    <id>github-maven-packages</id>
    <name>GitHub Maven Packages</name>
    <!-- NOTE: GH-Enterprise uses prefix https://maven.HOSTNAME/
        e.g., https://maven.github.myawesomeco.com/ 
     -->
    <url>https://maven.pkg.github.com/<my-username>/</url> 
  </repository>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
. . .
  - name: Set up JDK 11
    uses: actions/setup-java@v2
    with:
      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
    env:
      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_TOKEN: $

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: |.

This post is licensed under CC BY 4.0 by the author.

Python - Manage global packages with pipx

Git - Use gitattributes to control line endings