Skip to content

Commit

Permalink
Merge pull request #115 from whelk-io/develop
Browse files Browse the repository at this point in the history
Allow custom path for output file
  • Loading branch information
zteater authored Jun 14, 2021
2 parents 24109f0 + b67fb6c commit 0b81dd4
Show file tree
Hide file tree
Showing 43 changed files with 8,410 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/checkout@v2.3.4
- run: |
npm ci
npm test
test_job:
test-basic:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.3.4
- 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/checkout@v2.3.4
- 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/checkout@v2.3.4
- uses: ./
with:
output_file: custom.xml
- run: |
cat custom.xml
test-maven:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.3.4
- uses: ./
with:
output_file: custom.xml
- run: |
cat custom.xml
- uses: actions/setup-java@v1.4.3
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/checkout@v2.3.4
- uses: ./
with:
output_file: $GITHUB_WORKSPACE/custom.xml
- run: |
cat $GITHUB_WORKSPACE/custom.xml
- uses: actions/setup-java@v1.4.3
with:
java-version: 11
- run: |
cd test/maven;
./mvnw -s $GITHUB_WORKSPACE/custom.xml clean test
71 changes: 71 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ main, develop ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ main ]
schedule:
- cron: '15 17 * * 6'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'javascript' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed

steps:
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
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


57 changes: 41 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# maven-settings-xml-action

[![CodeFactor](https://www.codefactor.io/repository/github/whelk-io/maven-settings-xml-action/badge)](https://www.codefactor.io/repository/github/whelk-io/maven-settings-xml-action) ![build-test](https://github.com/whelk-io/maven-settings-xml-action/workflows/build-test/badge.svg)
[![CodeFactor](https://www.codefactor.io/repository/github/whelk-io/maven-settings-xml-action/badge)](https://www.codefactor.io/repository/github/whelk-io/maven-settings-xml-action) ![build-test](https://github.com/whelk-io/maven-settings-xml-action/workflows/build-test/badge.svg) [![CodeQL](https://github.com/whelk-io/maven-settings-xml-action/actions/workflows/codeql-analysis.yml/badge.svg?branch=main)](https://github.com/whelk-io/maven-settings-xml-action/actions/workflows/codeql-analysis.yml)

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 0b81dd4

Please sign in to comment.