Skip to content

Commit c1c64e7

Browse files
committed
manually generate settings.xml
1 parent ec556d6 commit c1c64e7

File tree

1 file changed

+41
-53
lines changed

1 file changed

+41
-53
lines changed

action.yml

Lines changed: 41 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -77,58 +77,46 @@ runs:
7777
echo "ARTIFACT_STORE_HOST=$HOST" >> $GITHUB_ENV
7878
REPO_ID="${{ inputs.aws-codeartifact-domain }}-${{ inputs.aws-codeartifact-repository }}"
7979
echo "REPO_ID=$REPO_ID" >> $GITHUB_OUTPUT
80-
# TOKEN used only in settings.xml file, while HOST is used both in settings.xml AND parent pom.xml 'distributionManagement'
81-
# so it is additionally put in env variable 'ARTIFACT_STORE_URL', see pom.xml files in 'java-parent' repos
82-
# Dec-31,2024 I triple checked: such env variable is JOB-scoped, so it indeed become available in job that calls this action
8380
84-
# First I tried "s4u/maven-settings-action@v3.0.0" - it was more concise, but it doesn't support pluginRepositories
85-
# There is no setting how to call the resulting profile (it is always "github"), but there is a setting to activate it (active_profiles)
86-
- name: Setup Maven settings.xml
87-
uses: whelk-io/maven-settings-xml-action@v22
88-
with:
89-
servers: >
90-
[
91-
{
92-
"id": "${{ steps.codeartifact.outputs.REPO_ID }}",
93-
"username": "aws",
94-
"password": "${{ steps.codeartifact.outputs.TOKEN }}"
95-
}
96-
]
97-
repositories: >
98-
[
99-
{
100-
"id": "central",
101-
"url": "https://central.maven.org/maven2/"
102-
},
103-
{
104-
"id": "mirror",
105-
"url": "https://repo1.maven.org/maven2/"
106-
},
107-
{
108-
"id": "${{ steps.codeartifact.outputs.REPO_ID }}",
109-
"url": "https://${{ steps.codeartifact.outputs.HOST }}/${{ inputs.aws-codeartifact-repository }}/maven/"
110-
}
111-
]
112-
plugin_repositories: >
113-
[
114-
{
115-
"id": "central",
116-
"url": "https://central.maven.org/maven2/"
117-
},
118-
{
119-
"id": "mirror",
120-
"url": "https://repo1.maven.org/maven2/"
121-
},
122-
{
123-
"id": "${{ steps.codeartifact.outputs.REPO_ID }}",
124-
"url": "https://${{ steps.codeartifact.outputs.HOST }}/${{ inputs.aws-codeartifact-repository }}/maven/"
125-
}
126-
]
127-
active_profiles: >
128-
[
129-
"github"
130-
]
81+
- name: Generate Maven settings.xml
82+
shell: bash
83+
run: |
84+
mkdir -p $HOME/.m2
85+
cat <<EOF > $HOME/.m2/settings.xml
86+
<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 http://maven.apache.org/xsd/settings-1.0.0.xsd">
87+
<activeProfiles>
88+
<activeProfile>github</activeProfile>
89+
</activeProfiles>
90+
<profiles>
91+
<profile>
92+
<id>github</id>
93+
<repositories>
94+
<repository>
95+
<id>${{ steps.codeartifact.outputs.REPO_ID }}</id>
96+
<url>https://${{ steps.codeartifact.outputs.HOST }}/${{ inputs.aws-codeartifact-repository }}/maven/</url>
97+
</repository>
98+
</repositories>
99+
<pluginRepositories>
100+
<pluginRepository>
101+
<id>${{ steps.codeartifact.outputs.REPO_ID }}</id>
102+
<url>https://${{ steps.codeartifact.outputs.HOST }}/${{ inputs.aws-codeartifact-repository }}/maven/</url>
103+
</pluginRepository>
104+
</pluginRepositories>
105+
</profile>
106+
</profiles>
107+
<servers>
108+
<server>
109+
<id>${{ steps.codeartifact.outputs.REPO_ID }}</id>
110+
<username>aws</username>
111+
<password>${{ steps.codeartifact.outputs.TOKEN }}</password>
112+
</server>
113+
</servers>
114+
<mirrors/>
115+
<pluginGroups/>
116+
<proxies/>
117+
</settings>
118+
EOF
131119
132-
# - name: Debug
133-
# shell: bash
134-
# run: cat /home/runner/.m2/settings.xml # see sample.settings.xml
120+
- name: Debug
121+
shell: bash
122+
run: cat $HOME/.m2/settings.xml # see ci.settings.xml

0 commit comments

Comments
 (0)