Skip to content
This repository has been archived by the owner on Jan 2, 2025. It is now read-only.

Commit

Permalink
Allow custom filename for output file (#112)
Browse files Browse the repository at this point in the history
* add custom filepath to input options, fixes #111

* update transitive dependency to clear new vulnerability

* add basic maven application for testing build, fixes #114
  • Loading branch information
zteater authored Jun 14, 2021
1 parent aa9c2ba commit 81bcd26
Show file tree
Hide file tree
Showing 42 changed files with 8,278 additions and 1,402 deletions.
131 changes: 128 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,151 @@ on: # rebuild any PRs and main branch changes
- develop

jobs:

build: # make sure build/ci work properly
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- run: |
npm ci
npm test
test_job:
test-basic:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- name: Create maven settings.xml
uses: ./
- uses: ./
with:
servers: '[{"id": "foo", "username": "fu", "password": "bar" }]'
mirrors: '[{ "id": "nexus", "mirrorOf": "!my-org-snapshots,*", "url": "http://redacted/nexus/content/groups/public" }]'
repositories: '[{"id": "foo", "url": "https://fu.bar"}]'
plugin_repositories: '[{"id": "foo-plugin", "url": "https://fu.bar.plugin"}]'
profiles: '[{ "id": "foo.profile", "name": "foo.profile", "url": "http://foo.bar.profile", "properties": { "foo": "property-1", "bar": "property-2"} }]'
plugin_groups: '[ "some.plugin.group.id", "some.other.plugin.group.id" ]'
active_profiles: '[ "foo.profile" ]'
- run: |
cat ~/.m2/settings.xml
test-expanded:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: ./
with:
repositories: >
[
{
"id": "some-repository",
"name": "some-repository-name",
"url": "http://some.repository.url",
"releases": {
"enabled": "true"
},
"snapshots": {
"enabled": "false"
}
}
]
plugin_repositories: >
[
{
"id": "some-plugin-repository",
"name": "some-plugin-repository-name",
"url": "http://some.plugin.repository.url",
"releases": {
"enabled": "true"
},
"snapshots": {
"enabled": "false"
}
}
]
servers: >
[
{
"id": "some-id",
"username": "${env.USER}",
"password": "${env.PASS}",
"configuration": {
"httpConfiguration": {
"all": {
"usePreemptive": "true"
}
}
}
}
]
mirrors: >
[
{
"id": "nexus",
"mirrorOf": "!my-org-snapshots,*",
"url": "http://redacted/nexus/content/groups/public"
}
]
profiles: >
[
{
"id": "foo.profile",
"name": "foo.profile",
"url": "http://foo.bar.profile",
"properties": {
"foo": "property-1",
"bar": "property-2"
}
}
]
plugin_groups: >
[
"some.plugin.group.id",
"some.other.plugin.group.id"
]
active_profiles: >
[
"some-profile"
]
output_file: .m2/settings.xml
- run: |
cat .m2/settings.xml
test-filepath:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: ./
with:
output_file: custom.xml
- run: |
cat custom.xml
test-maven:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: ./
with:
output_file: custom.xml
- run: |
cat custom.xml
- uses: actions/[email protected]
with:
java-version: 11
- run: |
cd test/maven;
./mvnw -s /home/runner/work/maven-settings-xml-action/maven-settings-xml-action/custom.xml clean test
test-env-filepath:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: ./
with:
output_file: $GITHUB_WORKSPACE/custom.xml
- run: |
cat $GITHUB_WORKSPACE/custom.xml
- uses: actions/[email protected]
with:
java-version: 11
- run: |
cd test/maven;
./mvnw -s $GITHUB_WORKSPACE/custom.xml clean test
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
.project
.classpath
.settings/
test/maven/target/
### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
Expand Down Expand Up @@ -181,6 +184,7 @@ web_modules/

# Stores VSCode versions used for testing VSCode extensions
.vscode-test
.vscode/

# yarn v2

Expand All @@ -189,3 +193,5 @@ web_modules/
.yarn/build-state.yml
.pnp.*
.idea


55 changes: 40 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

Github Action to create maven settings (`~/.m2/settings.xml`).

Supports `<servers>`, `<repositories>`, `<pluginRepositories>`, `<mirrors>`, and `<profiles>`.
Supports `<servers>`, `<repositories>`, `<pluginRepositories>`, `<pluginGroups>`, `<mirrors>`, `<activeProfiles>`, and `<profiles>`.

## Inputs

Expand Down Expand Up @@ -78,21 +78,32 @@ The `profile` element in the `settings.xml` is a truncated version of the `pom.x

Reference: [Maven Settings > Profiles](http://maven.apache.org/settings.html#profiles)


### `activeProfiles`
### `active_profiles`
**Optional** json array of active profiles to add to settings.xml

Set of `activeProfile` elements, which each have a value of a `profile` `id`. Any `profile` `id` defined as an `activeProfile` will be active, regardless of any environment settings. If no matching profile is found nothing will happen. For example, if `env-test` is an `activeProfile`, a profile in a `pom.xml` (or `profile.xml`) with a corresponding `id` will be active. If no such profile is found then execution will continue as normal.

Reference: [Maven Settings > Active Profiles](https://maven.apache.org/settings.html#Active_Profiles)

### `output_file`
**Optional** String path of to generate `settings.xml`. By default, `~/.m2/settings.xml` is used.

When using a custom `output_file`, for example:
```yaml
- uses: whelk-io/maven-settings-xml-action@v18
with:
output_file: foo/custom.xml
```

The generated `settings.xml` will be created at `/home/runner/work/{repo}/foo/custom.xml`, which can be referenced in maven steps using `mvn --settings foo/custom.xml {goal}`.

---

## Basic Usage

````yaml
- name: maven-settings-xml-action
uses: whelk-io/maven-settings-xml-action@v17
uses: whelk-io/maven-settings-xml-action@v18
with:
repositories: '[{ "id": "some-repository", "url": "http://some.repository.url" }]'
plugin_repositories: '[{ "id": "some-plugin-repository", "url": "http://some.plugin.repository.url" }]'
Expand Down Expand Up @@ -146,9 +157,9 @@ Reference: [Maven Settings > Active Profiles](https://maven.apache.org/settings.

````yaml
- name: maven-settings-xml-action
uses: whelk-io/maven-settings-xml-action@v17
uses: whelk-io/maven-settings-xml-action@v18
with:
repositories: |
repositories: >
[
{
"id": "some-repository",
Expand All @@ -162,7 +173,7 @@ Reference: [Maven Settings > Active Profiles](https://maven.apache.org/settings.
}
}
]
plugin_repositories: |
plugin_repositories: >
[
{
"id": "some-plugin-repository",
Expand All @@ -176,7 +187,7 @@ Reference: [Maven Settings > Active Profiles](https://maven.apache.org/settings.
}
}
]
servers: |
servers: >
[
{
"id": "some-id",
Expand All @@ -191,15 +202,15 @@ Reference: [Maven Settings > Active Profiles](https://maven.apache.org/settings.
}
}
]
mirrors: |
mirrors: >
[
{
"id": "nexus",
"mirrorOf": "!my-org-snapshots,*",
"url": "http://redacted/nexus/content/groups/public"
}
]
profiles: |
profiles: >
[
{
"id": "foo.profile",
Expand All @@ -211,15 +222,16 @@ Reference: [Maven Settings > Active Profiles](https://maven.apache.org/settings.
}
}
]
plugin_groups: |
[
"some.plugin.group.id",
plugin_groups: >
[
"some.plugin.group.id",
"some.other.plugin.group.id"
]
active_profiles: |
[
active_profiles: >
[
"some-profile"
]
output_file: .m2/settings.xml
````

**Output**
Expand Down Expand Up @@ -331,3 +343,16 @@ See [CONTRIBUTING.md](Contributing) for guidelines for forking and contributing
**Create Distribution**

`npm run build`


## Run Actions Locally

**Install [`Act`](https://github.com/nektos/act)**

`brew install act`

**Run Step**

`act -s GITHUB_TOKEN={token} -j {step}`

Example: `act -s GITHUB_TOKEN=lk34j56lk34j5lk34j5dkllsldf -j test-basic`
2 changes: 2 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ inputs:
required: false
active_profiles:
description: 'json array of profile ids to add to settings.xml'
output_file:
description: 'path to generated file, default is .m2/settings.xml'
runs:
using: 'node12'
main: 'dist/index.js'
Loading

0 comments on commit 81bcd26

Please sign in to comment.