Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/s4u/maven-settings-action
This action setup maven settings.xml
https://github.com/s4u/maven-settings-action
github-actions hacktoberfest maven
Last synced: 3 days ago
JSON representation
This action setup maven settings.xml
- Host: GitHub
- URL: https://github.com/s4u/maven-settings-action
- Owner: s4u
- License: mit
- Created: 2019-10-01T20:11:01.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-12-16T10:00:14.000Z (19 days ago)
- Last Synced: 2024-12-27T02:43:05.480Z (8 days ago)
- Topics: github-actions, hacktoberfest, maven
- Language: JavaScript
- Homepage:
- Size: 2.44 MB
- Stars: 111
- Watchers: 4
- Forks: 26
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# maven-settings-action
[![Test](https://github.com/s4u/maven-settings-action/workflows/Test/badge.svg)](https://github.com/s4u/maven-settings-action/actions?query=workflow%3ATest)
[![Audit](https://github.com/s4u/maven-settings-action/workflows/Audit/badge.svg)](https://github.com/s4u/maven-settings-action/actions?query=workflow%3AAudit)This action sets up Maven environments for use in GitHub Actions by:
- create maven settings.xml
- set ```interactiveMode``` to false - useful in CI system
- after job finish generated settings.xml will be removed to prevent cache or left sensitive data on build system
- add server to servers with id=github, username=$GITHUB_ACTOR and password=$GITHUB_TOKEN# Contributions
- Contributions are welcome!
- Give :star: - if you want to encourage me to work on a project
- Don't hesitate to create issues for new features you dream of or if you suspect some bug# Project versioning
This project uses [Semantic Versioning](https://semver.org/).
We recommended to use the latest and specific release version.In order to keep your project dependencies up to date you can watch this repository *(Releases only)*
or use automatic tools like [Dependabot](https://docs.github.com/en/code-security/supply-chain-security/keeping-your-dependencies-updated-automatically/about-dependabot-version-updates).# Usage
You can try our action [Setup Maven Action](https://github.com/marketplace/actions/setup-maven-action) for completely maven environment setup.
See [action.yml](action.yml)
## default ```settings.xml```
```yml
steps:
- uses: s4u/[email protected]
```## ```settings.xml``` with servers section
```yml
steps:
- uses: s4u/[email protected]
with:
servers: '[{"id": "serverId", "username": "username", "password": "password"}]'
```Also you can use `path` argument if your settings.xml is stored in different location.
All `server` attributes may be specified:
* `id` _(required)_
* `username`
* `password`
* `privateKey`
* `passphrase`
* `filePermissions`
* `directoryPermissions`
* `configuration`Please refer to the [servers](http://maven.apache.org/settings.html#Servers) documentation for more information.
## ```settings.xml``` with servers section and additional configuration
``` yml
steps:
- uses: s4u/[email protected]
with:
servers: |
[{
"id": "serverId",
"configuration": {
"item1": "value1",
"item2": {
"item21": "value21",
"item22": "value22"
}
}
}]
```result will be:
```xml
serverId
value1
value21
value22
```
## ```settings.xml``` with mirrors section
```yml
steps:
- uses: s4u/[email protected]
with:
mirrors: '[{"id": "mirrorId", "name": "mirrorName", "mirrorOf": "mirrorOf", "url": "mirrorUrl"}]'
```## ```settings.xml``` with proxies section
```yml
step:
- uses: s4u/[email protected]
with:
proxies: '[{"id": "proxyId", "active": "isActive", "protocol": "proxyProtocol", "host": "proxyHost", "port": "proxyPort", "nonProxyHosts": "nonProxyHost", "user": "proxUser", "password": "proxPassword"}]'
```
Note: Authentication details are optional.## ```settings.xml``` with properties
```yml
steps:
- uses: s4u/[email protected]
with:
properties: '[{"propertyName1": "propertyValue1"}, {"propertyName2": "propertyValue2"}]'
```## ```settings.xml``` with https://oss.sonatype.org/content/repositories/snapshots in repository list
```yml
steps:
- uses: s4u/[email protected]
with:
sonatypeSnapshots: true
```## ```settings.xml``` with https://repository.apache.org/snapshots/ in repository list
```yml
steps:
- uses: s4u/[email protected]
with:
apacheSnapshots: true
```## Do not override existing ```settings.xml```, from version **2.0** file is override by default :
```yml
steps:
- uses: s4u/[email protected]
with:
override: false
```## Do not add github to server in ```settings.xml```, by default is added:
```yml
steps:
- uses: s4u/[email protected]
with:
githubServer: false
```## ```settings.xml``` with special server item configuration for oracle repository [Oracle Maven Repository](https://docs.oracle.com/middleware/1213/core/MAVEN/config_maven_repo.htm#MAVEN9015)
```yml
steps:
- uses: s4u/[email protected]
with:
oracleServers: '[{"id": "serverId", "username": "username", "password": "password"}]'
```## ```settings.xml``` with [Oracle Maven Repository](https://docs.oracle.com/middleware/1213/core/MAVEN/config_maven_repo.htm#MAVEN9017)
```yml
steps:
- uses: s4u/[email protected]
with:
oracleRepo: true
```## ```settings.xml``` with custom repositories
```yml
steps:
- uses: s4u/[email protected]
with:
repositories: '[{"id":"repoId","name":"repoName","url":"url","snapshots":{"enabled":true}}]'
```## ```settings.xml``` with custom plugin repositories
```yml
steps:
- uses: s4u/[email protected]
with:
pluginRepositories: '[{"id":"repoId","name":"repoName","url":"url","snapshots":{"enabled":true}}]'
```## GitHub actions secrets
It is also possible pass in Github Secrets e.g.
``` yml
steps:
- uses: s4u/[email protected]
with:
servers: |
[{
"id": "sonatype-nexus-snapshots",
"username": "${{ secrets.SONATYPE_USERNAME }}",
"password": "${{ secrets.SONATYPE_PASSWORD }}"
}]
```**Note**: secrets are *not* passed in if the workflow is triggered from a forked repository. See [here](https://docs.github.com/en/free-pro-team@latest/actions/reference/encrypted-secrets#using-encrypted-secrets-in-a-workflow) for further information. This can be avoided by using `if` triggers on the job e.g. `if: github.event_name == 'push'`.
# Notes
**maven-settings-action** should be put at the latest position before maven run in order to avoid override ```setting.xml``` by another action
```yml
steps:
- uses: actions/checkout@v2- uses: actions/cache@v2
with:
path: ~/.m2/repository
key: maven-${{ hashFiles('**/pom.xml') }}
restore-keys: maven-- uses: actions/setup-java@v1
with:
java-version: 8- uses: s4u/[email protected]
- run: mvn verify
```# License
The scripts and documentation in this project are released under the [MIT License](LICENSE).