Skip to content

Commit 0ea6003

Browse files
Onboarding new maven snapshots publishing to s3 (UBI) (opensearch-project#140)
Signed-off-by: Peter Zhu <[email protected]>
1 parent 575cb83 commit 0ea6003

File tree

4 files changed

+77
-10
lines changed

4 files changed

+77
-10
lines changed

.github/workflows/backport.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Backport
2+
on:
3+
pull_request_target:
4+
types:
5+
- closed
6+
- labeled
7+
8+
jobs:
9+
backport:
10+
name: Backport
11+
runs-on: ubuntu-latest
12+
# Only react to merged PRs for security reasons.
13+
# See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target.
14+
if: >
15+
github.event.pull_request.merged
16+
&& (
17+
github.event.action == 'closed'
18+
|| (
19+
github.event.action == 'labeled'
20+
&& contains(github.event.label.name, 'backport')
21+
)
22+
)
23+
permissions:
24+
contents: write
25+
pull-requests: write
26+
steps:
27+
- name: GitHub App token
28+
id: github_app_token
29+
uses: tibdex/[email protected]
30+
with:
31+
app_id: ${{ secrets.APP_ID }}
32+
private_key: ${{ secrets.APP_PRIVATE_KEY }}
33+
installation_id: 22958780
34+
35+
- name: Backport
36+
uses: VachaShah/[email protected]
37+
with:
38+
github_token: ${{ steps.github_app_token.outputs.token }}
39+
head_template: backport/backport-<%= number %>-to-<%= base %>
40+
failure_labels: backport-failed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Delete merged branch of the backport PRs
2+
on:
3+
pull_request:
4+
types:
5+
- closed
6+
7+
jobs:
8+
delete-branch:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: write
12+
if: github.repository == 'opensearch-project/user-behavior-insights' && startsWith(github.event.pull_request.head.ref,'backport/')
13+
steps:
14+
- name: Delete merged branch
15+
uses: actions/github-script@v7
16+
with:
17+
script: |
18+
github.rest.git.deleteRef({
19+
owner: context.repo.owner,
20+
repo: context.repo.repo,
21+
ref: `heads/${context.payload.pull_request.head.ref}`,
22+
})

.github/workflows/maven-publish.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,14 @@ jobs:
3131
export-env: true
3232
env:
3333
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
34-
SONATYPE_USERNAME: op://opensearch-infra-secrets/maven-central-portal-credentials/username
35-
SONATYPE_PASSWORD: op://opensearch-infra-secrets/maven-central-portal-credentials/password
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
36+
37+
- name: Configure AWS credentials
38+
uses: aws-actions/configure-aws-credentials@v5
39+
with:
40+
role-to-assume: ${{ env.MAVEN_SNAPSHOTS_S3_ROLE }}
41+
aws-region: us-east-1
3642

3743
- name: Publish snapshots to maven
3844
run: |

build.gradle

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ buildscript {
5454

5555
repositories {
5656
mavenLocal()
57-
maven { url "https://central.sonatype.com/repository/maven-snapshots/" }
58-
maven { url "https://aws.oss.sonatype.org/content/repositories/snapshots" }
57+
maven { url "https://ci.opensearch.org/ci/dbc/snapshots/maven/" }
5958
mavenCentral()
6059
maven { url "https://plugins.gradle.org/m2/" }
6160
maven { url 'https://jitpack.io' }
@@ -69,8 +68,7 @@ buildscript {
6968

7069
repositories {
7170
mavenLocal()
72-
maven { url "https://central.sonatype.com/repository/maven-snapshots/" }
73-
maven { url "https://aws.oss.sonatype.org/content/repositories/snapshots" }
71+
maven { url "https://ci.opensearch.org/ci/dbc/snapshots/maven/" }
7472
mavenCentral()
7573
maven { url "https://plugins.gradle.org/m2/" }
7674
}
@@ -127,10 +125,11 @@ publishing {
127125
repositories {
128126
maven {
129127
name = "Snapshots"
130-
url = "https://central.sonatype.com/repository/maven-snapshots/"
131-
credentials {
132-
username System.getenv("SONATYPE_USERNAME")
133-
password System.getenv("SONATYPE_PASSWORD")
128+
url = System.getenv("MAVEN_SNAPSHOTS_S3_REPO")
129+
credentials(AwsCredentials) {
130+
accessKey = System.getenv("AWS_ACCESS_KEY_ID")
131+
secretKey = System.getenv("AWS_SECRET_ACCESS_KEY")
132+
sessionToken = System.getenv("AWS_SESSION_TOKEN")
134133
}
135134
}
136135
maven {

0 commit comments

Comments
 (0)