Move to settings-path
This commit is contained in:
parent
ae11e1a1b6
commit
ce88feea94
|
@ -118,9 +118,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.
|
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 within a Shared Runner
|
## Apache Maven within a self-hosted runner
|
||||||
|
|
||||||
When using an Actions shared runner the default `$HOME` directory can be shared by a number of workflows at the same time which could overwrite existing settings file. Setting the `m2-home` variable allows you to choose a unique location for your settings file.
|
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
|
```yaml
|
||||||
jobs:
|
jobs:
|
||||||
|
@ -137,11 +137,11 @@ jobs:
|
||||||
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
|
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
|
||||||
username: ${{ github.actor }} # username for server authentication
|
username: ${{ github.actor }} # username for server authentication
|
||||||
password: ${{ github.token }} # password or token for authentication
|
password: ${{ github.token }} # password or token for authentication
|
||||||
m2-home: ${{ $GITHUB_WORKSPACE }} # location for the settings.xml file
|
settings-path: ./config # location for the settings.xml file
|
||||||
- name: Build with Maven
|
- name: Build with Maven
|
||||||
run: mvn -B package --file pom.xml
|
run: mvn -B package --file pom.xml
|
||||||
- name: Publish to GitHub Packages Apache Maven
|
- name: Publish to GitHub Packages Apache Maven
|
||||||
run: mvn deploy -s ${{ $GITHUB_WORKSPACE }}/settings.xml
|
run: mvn deploy -s ./config/settings.xml
|
||||||
```
|
```
|
||||||
|
|
||||||
# License
|
# License
|
||||||
|
|
|
@ -35,7 +35,7 @@ describe('auth tests', () => {
|
||||||
|
|
||||||
const altHome = path.join(__dirname, 'runner', 'settings');
|
const altHome = path.join(__dirname, 'runner', 'settings');
|
||||||
const altSettingsFile = path.join(altHome, auth.SETTINGS_FILE);
|
const altSettingsFile = path.join(altHome, auth.SETTINGS_FILE);
|
||||||
process.env[`INPUT_M2-HOME`] = altHome;
|
process.env[`INPUT_SETTINGS-PATH`] = altHome;
|
||||||
await io.rmRF(altHome); // ensure it doesn't already exist
|
await io.rmRF(altHome); // ensure it doesn't already exist
|
||||||
|
|
||||||
await auth.configAuthentication(id, username, password);
|
await auth.configAuthentication(id, username, password);
|
||||||
|
@ -49,7 +49,7 @@ describe('auth tests', () => {
|
||||||
auth.generate(id, username, password)
|
auth.generate(id, username, password)
|
||||||
);
|
);
|
||||||
|
|
||||||
delete process.env[`INPUT_M2-HOME`];
|
delete process.env[`INPUT_SETTINGS-PATH`];
|
||||||
await io.rmRF(altHome);
|
await io.rmRF(altHome);
|
||||||
}, 100000);
|
}, 100000);
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,9 @@ inputs:
|
||||||
description: 'Password or token for authentication to the Apache Maven
|
description: 'Password or token for authentication to the Apache Maven
|
||||||
repository.'
|
repository.'
|
||||||
required: false
|
required: false
|
||||||
|
settings-path:
|
||||||
|
description: 'Path to where the settings.xml file will be written.'
|
||||||
|
required: false
|
||||||
runs:
|
runs:
|
||||||
using: 'node12'
|
using: 'node12'
|
||||||
main: 'dist/index.js'
|
main: 'dist/index.js'
|
||||||
|
|
Binary file not shown.
|
@ -19,8 +19,8 @@ export async function configAuthentication(
|
||||||
// when an alternate m2 location is specified use only that location (no .m2 directory)
|
// when an alternate m2 location is specified use only that location (no .m2 directory)
|
||||||
// otherwise use the home/.m2/ path
|
// otherwise use the home/.m2/ path
|
||||||
const directory: string = path.join(
|
const directory: string = path.join(
|
||||||
core.getInput('m2-home') || os.homedir(),
|
core.getInput('settings-path') || os.homedir(),
|
||||||
core.getInput('m2-home') ? '' : M2_DIR
|
core.getInput('settings-path') ? '' : M2_DIR
|
||||||
);
|
);
|
||||||
await io.mkdirP(directory);
|
await io.mkdirP(directory);
|
||||||
core.debug(`created directory ${directory}`);
|
core.debug(`created directory ${directory}`);
|
||||||
|
|
Loading…
Reference in New Issue