Skip to content

Commit

Permalink
Github action mvn cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
Quentin Castel committed Nov 20, 2019
0 parents commit 7998d36
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM qcastel/maven-git-gpg:latest

COPY ./mvn-action.sh /usr/local/bin
COPY ./settings.xml /usr/share/maven/conf
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# github action maven cmd

The GitHub Action for Maven wraps the Maven CLI to enable Maven cmd to be run from a docker image.
It uses JDK 11 and help you setting up the settings.xml for your private maven repository

# Usage

## Maven release

For a simple repo with not much protection and private dependency, you can do:

```
- name: Build
uses: qcastel/github-actions-maven/actions/maven@master
with:
maven-args: "clean install"
```

If you got a private maven repo to setup in the settings.xml, you can do:
Note: we recommend putting those values in your repo secrets.

```
- name: Build
uses: qcastel/github-actions-maven/actions/maven@master
with:
maven-repo-server-id: ${{ secrets.MVN_REPO_PRIVATE_REPO_USER }}
maven-repo-server-username: ${{ secrets.MVN_REPO_PRIVATE_REPO_USER }}
maven-repo-server-password: ${{ secrets.MVN_REPO_PRIVATE_REPO_PASSWORD }}
maven-args: "clean install"
```



We welcome contributions! If your usecase is slightly different than us, just suggest a RFE or contribute to this repo directly.

# License
The Dockerfile and associated scripts and documentation in this project are released under the MIT License.
38 changes: 38 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# action.yml
name: 'OB release'
author: https://github.com/qcastel
description: 'Release our java libraries for open banking'
branding:
color: blue
icon: unlock
inputs:
maven-local-repo-path:
description: 'The maven local repository path'
required: false
default: '$M2_HOME/repository'
maven-repo-server-id:
description: 'Maven server repository id to push the artefacts to'
required: true
maven-repo-server-username:
description: 'Maven server repository username'
required: true
maven-repo-server-password:
description: 'Maven server repository password'
required: true
maven-args:
description: 'The maven arguments'
required: false
default: ''

runs:
using: 'docker'
image: 'Dockerfile'
args:
- mvn-action.sh
- ${{ inputs.maven-args }}
env:
MAVEN_LOCAL_REPO_PATH: ${{ inputs.maven-local-repo-path }}
MAVEN_REPO_SERVER_ID: ${{ inputs.maven-repo-server-id }}
MAVEN_REPO_SERVER_USERNAME: ${{ inputs.maven-repo-server-username }}
MAVEN_REPO_SERVER_PASSWORD: ${{ inputs.maven-repo-server-password }}
MAVEN_ARGS: ${{ inputs.maven-args }}
12 changes: 12 additions & 0 deletions mvn-action.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
set -e

echo "JAVA_HOME = $JAVA_HOME"
JAVA_HOME="/usr/local/openjdk-11/"
# Setup maven local repo
if [[ -n "$MAVEN_LOCAL_REPO_PATH" ]]; then
MAVEN_REPO_LOCAL="-Dmaven.repo.local=$MAVEN_LOCAL_REPO_PATH"
fi

# Do the copyright verification
mvn $MAVEN_REPO_LOCAL -ntp $*
14 changes: 14 additions & 0 deletions settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<!-- This id must match the distributionManagement section in pom.xml -->
<id>${env.MAVEN_REPO_SERVER_ID}</id>
<username>${env.MAVEN_REPO_SERVER_USERNAME}</username>
<!-- Credential stored in Travis CI -->
<password>${env.MAVEN_REPO_SERVER_PASSWORD}</password>
</server>
</servers>
</settings>

0 comments on commit 7998d36

Please sign in to comment.