From 53ac717e09ee911c7c5ac6b51f670384756dafbc Mon Sep 17 00:00:00 2001 From: Marcono1234 Date: Mon, 17 May 2021 15:38:02 +0200 Subject: [PATCH] Improve README and advanced usage guide (#174) --- README.md | 4 +-- docs/advanced-usage.md | 64 ++++++++++++++++++++---------------------- 2 files changed, 33 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index d7b62a1..e846889 100644 --- a/README.md +++ b/README.md @@ -111,8 +111,8 @@ jobs: ## License -The scripts and documentation in this project are released under the [MIT License](LICENSE) +The scripts and documentation in this project are released under the [MIT License](LICENSE). ## Contributions -Contributions are welcome! See [Contributor's Guide](docs/contributors.md) +Contributions are welcome! See [Contributor's Guide](CONTRIBUTING.md) diff --git a/docs/advanced-usage.md b/docs/advanced-usage.md index 400505e..6a2d1ab 100644 --- a/docs/advanced-usage.md +++ b/docs/advanced-usage.md @@ -129,7 +129,6 @@ jobs: ```yaml jobs: build: - runs-on: ubuntu-latest steps: @@ -207,7 +206,7 @@ The two `settings.xml` files created from the above example look like the follow ``` -***NOTE***: The `settings.xml` file is created in the Actions $HOME/.m2 directory. If you have an existing `settings.xml` file at that location, it will be overwritten. See below for using the `settings-path` to change your `settings.xml` file location. +***NOTE***: The `settings.xml` file is created in the Actions `$HOME/.m2` directory. If you have an existing `settings.xml` file at that location, it will be overwritten. See [below](#apache-maven-with-a-settings-path) for using the `settings-path` to change your `settings.xml` file location. If you don't want to overwrite the `settings.xml` file, you can set `overwrite-settings: false` @@ -234,6 +233,34 @@ If `gpg-private-key` input is provided, the private key will be written to a fil See the help docs on [Publishing a Package](https://help.github.com/en/github/managing-packages-with-github-packages/configuring-apache-maven-for-use-with-github-packages#publishing-a-package) for more information on the `pom.xml` file. +## Apache Maven with a settings path + +When using an Actions self-hosted runner with multiple shared runners the default `$HOME` directory can be shared by a number runners at the same time which could overwrite existing settings file. Setting the `settings-path` variable allows you to choose a unique location for your settings file. + +```yaml +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 11 for Shared Runner + uses: actions/setup-java@v2 + with: + distribution: '' + java-version: '11' + server-id: github # Value of the distributionManagement/repository/id field of the pom.xml + settings-path: ${{ github.workspace }} # location for the settings.xml file + + - name: Build with Maven + run: mvn -B package --file pom.xml + + - name: Publish to GitHub Packages Apache Maven + run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml + env: + GITHUB_TOKEN: ${{ github.token }} +``` + ## Publishing using Gradle ```yaml jobs: @@ -264,38 +291,9 @@ jobs: See the help docs on [Publishing a Package with Gradle](https://help.github.com/en/github/managing-packages-with-github-packages/configuring-gradle-for-use-with-github-packages#example-using-gradle-groovy-for-a-single-package-in-a-repository) for more information on the `build.gradle` configuration file. -## Apache Maven with a settings path - -When using an Actions self-hosted runner with multiple shared runners the default `$HOME` directory can be shared by a number runners at the same time which could overwrite existing settings file. Setting the `settings-path` variable allows you to choose a unique location for your settings file. - -```yaml -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Set up JDK 11 for Shared Runner - uses: actions/setup-java@v2 - with: - distribution: '' - java-version: '11' - server-id: github # Value of the distributionManagement/repository/id field of the pom.xml - settings-path: ${{ github.workspace }} # location for the settings.xml file - - - name: Build with Maven - run: mvn -B package --file pom.xml - - - name: Publish to GitHub Packages Apache Maven - run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml - env: - GITHUB_TOKEN: ${{ github.token }} -``` - ## Hosted Tool Cache -GitHub Hosted Runners have a tool cache that comes with some Java versions pre-installed. This tool cache helps speed up runs and tool setup by not requiring any new downloads. There is an environment variable called `RUNNER_TOOL_CACHE` on each runner that describes the location of this tools cache and this is where you can find the pre-installed versions of Java. `setup-java` works by taking a specific version of Java in this tool cache and adding it to PATH if the version, architecture and distribution match. +GitHub Hosted Runners have a tool cache that comes with some Java versions pre-installed. This tool cache helps speed up runs and tool setup by not requiring any new downloads. There is an environment variable called `RUNNER_TOOL_CACHE` on each runner that describes the location of this tools cache and this is where you can find the pre-installed versions of Java. `setup-java` works by taking a specific version of Java in this tool cache and adding it to PATH if the version, architecture and distribution match. Currently, LTS versions of Adopt OpenJDK (`adopt`) are cached on the GitHub Hosted Runners. -The tools cache gets updated on a weekly basis. For information regarding locally cached versions of Java on GitHub hosted runners, check out [GitHub Actions Virtual Environments](https://github.com/actions/virtual-environments). +The tools cache gets updated on a weekly basis. For information regarding locally cached versions of Java on GitHub hosted runners, check out [GitHub Actions Virtual Environments](https://github.com/actions/virtual-environments).