Skip to content

Commit dead31f

Browse files
[Backport 2.19] Onboarding new maven snapshots publishing to s3 (query-insights) (#469)
Signed-off-by: Peter Zhu <[email protected]>
1 parent 33e0321 commit dead31f

File tree

2 files changed

+25
-18
lines changed

2 files changed

+25
-18
lines changed

.github/workflows/maven-publish.yml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,29 @@ jobs:
1818

1919
steps:
2020
- uses: actions/checkout@v4
21-
- name: Set up JDK 11
21+
- name: Set up JDK 21
2222
uses: actions/setup-java@v3
2323
with:
2424
distribution: temurin # Temurin is a distribution of adoptium
25-
java-version: 11
25+
java-version: 21
26+
27+
- name: Load secret
28+
uses: 1password/load-secrets-action@v2
29+
with:
30+
# Export loaded secrets as environment variables
31+
export-env: true
32+
env:
33+
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
34+
MAVEN_SNAPSHOTS_S3_REPO: op://opensearch-infra-secrets/maven-snapshots-s3/repo
35+
MAVEN_SNAPSHOTS_S3_ROLE: op://opensearch-infra-secrets/maven-snapshots-s3/role
2636

2737
- name: Configure AWS credentials
28-
uses: aws-actions/configure-aws-credentials@v4
38+
uses: aws-actions/configure-aws-credentials@v5
2939
with:
30-
role-to-assume: ${{ secrets.PUBLISH_SNAPSHOTS_ROLE }}
40+
role-to-assume: ${{ env.MAVEN_SNAPSHOTS_S3_ROLE }}
3141
aws-region: us-east-1
3242

3343
- name: Publish snapshots to maven
3444
run: |
35-
export SONATYPE_USERNAME=$(aws secretsmanager get-secret-value --secret-id maven-snapshots-username --query SecretString --output text)
36-
export SONATYPE_PASSWORD=$(aws secretsmanager get-secret-value --secret-id maven-snapshots-password --query SecretString --output text)
37-
echo "::add-mask::$SONATYPE_USERNAME"
38-
echo "::add-mask::$SONATYPE_PASSWORD"
3945
# For JS plugin zip
4046
./gradlew publishPluginZipPublicationToSnapshotsRepository

build.gradle

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ buildscript {
2525

2626
repositories {
2727
mavenLocal()
28-
maven { url "https://aws.oss.sonatype.org/content/repositories/snapshots" }
28+
maven { url "https://ci.opensearch.org/ci/dbc/snapshots/maven/" }
2929
mavenCentral()
3030
maven { url "https://plugins.gradle.org/m2/" }
3131
}
@@ -132,10 +132,11 @@ publishing {
132132
repositories {
133133
maven {
134134
name = "Snapshots"
135-
url = "https://aws.oss.sonatype.org/content/repositories/snapshots"
136-
credentials {
137-
username "$System.env.SONATYPE_USERNAME"
138-
password "$System.env.SONATYPE_PASSWORD"
135+
url = System.getenv("MAVEN_SNAPSHOTS_S3_REPO")
136+
credentials(AwsCredentials) {
137+
accessKey = System.getenv("AWS_ACCESS_KEY_ID")
138+
secretKey = System.getenv("AWS_SECRET_ACCESS_KEY")
139+
sessionToken = System.getenv("AWS_SESSION_TOKEN")
139140
}
140141
}
141142
}
@@ -187,15 +188,15 @@ allprojects {
187188
}
188189

189190
repositories {
190-
mavenLocal()
191-
maven { url "https://aws.oss.sonatype.org/content/repositories/snapshots" }
192-
mavenCentral()
193-
maven { url "https://plugins.gradle.org/m2/" }
191+
mavenLocal()
192+
maven { url "https://ci.opensearch.org/ci/dbc/snapshots/maven/" }
193+
mavenCentral()
194+
maven { url "https://plugins.gradle.org/m2/" }
194195
}
195196

196197
ext {
197198
getSecurityPluginDownloadLink = { ->
198-
var repo = "https://aws.oss.sonatype.org/content/repositories/snapshots/org/opensearch/plugin/" +
199+
var repo = "https://ci.opensearch.org/ci/dbc/snapshots/maven/org/opensearch/plugin/" +
199200
"opensearch-security/$opensearch_build_snapshot/"
200201
var metadataFile = Paths.get(projectDir.toString(), "build", "maven-metadata.xml").toAbsolutePath().toFile()
201202
download.run {

0 commit comments

Comments
 (0)