Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Release Drafter and Jenkinsfile with Docker credentials and promotions #860

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 35 additions & 11 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,17 @@ env:
java-version: '11'
gradle-version: '8.0.2'

permissions:
id-token: write
contents: read

jobs:
draft-a-release:
name: Draft a release
if: github.repository == 'opensearch-project/opensearch-migrations'
runs-on: ubuntu-latest
outputs:
dockerhub-password: ${{ steps.retrieve-values.outputs.dockerhub-password }}
steps:
- uses: actions/setup-java@v4
with:
Expand Down Expand Up @@ -48,17 +55,34 @@ jobs:
docker tag migrations/traffic_replayer:latest opensearchstaging/opensearch-migrations-traffic-replayer:${{ steps.get_data.outputs.version }}
docker tag migrations/capture_proxy:latest opensearchstaging/opensearch-migrations-traffic-capture-proxy:${{ steps.get_data.outputs.version }}
docker tag migrations/reindex_from_snapshot:latest opensearchstaging/opensearch-migrations-reindex-from-snapshot:${{ steps.get_data.outputs.version }}
# - name: Login to DockerHub
# uses: docker/login-action@v1
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}
# - name: Push Docker image to Docker Hub
# run: |
# docker push opensearchstaging/opensearch-migrations-console:${{ steps.get_data.outputs.version }}
# docker push opensearchstaging/opensearch-migrations-traffic-replayer:${{ steps.get_data.outputs.version }}
# docker push opensearchstaging/opensearch-migrations-traffic-capture-proxy:${{ steps.get_data.outputs.version }}
# docker push opensearchstaging/opensearch-migrations-reindex-from-snapshot:${{ steps.get_data.outputs.version }}
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.MIGRATIONS_DOCKER_ROLE }}
aws-region: us-east-1
- name: Retrieve Values
id: retrieve-values
run: |
DOCKERHUB_PASSWORD=`aws secretsmanager get-secret-value --secret-id jenkins-staging-dockerhub-credential --query SecretString --output text`
echo "::add-mask::$DOCKERHUB_PASSWORD"
echo "dockerhub-password=$DOCKERHUB_PASSWORD" >> $GITHUB_OUTPUT
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.MIGRATIONS_DOCKER_USERNAME }}
password: ${{ steps.retrieve-values.outputs.dockerhub-password }}
- name: Push Docker image to Docker Hub
run: |
docker push opensearchstaging/opensearch-migrations-console:${{ steps.get_data.outputs.version }}
docker push opensearchstaging/opensearch-migrations-console:latest
docker push opensearchstaging/opensearch-migrations-traffic-replayer:${{ steps.get_data.outputs.version }}
docker push opensearchstaging/opensearch-migrations-traffic-replayer:latest
docker push opensearchstaging/opensearch-migrations-traffic-capture-proxy:${{ steps.get_data.outputs.version }}
docker push opensearchstaging/opensearch-migrations-traffic-capture-proxy:latest
docker push opensearchstaging/opensearch-migrations-reindex-from-snapshot:${{ steps.get_data.outputs.version }}
docker push opensearchstaging/opensearch-migrations-reindex-from-snapshot:latest
- name: Logout to DockerHub
if: always()
run: docker logout
- name: Draft a release
uses: softprops/action-gh-release@v2
with:
Expand Down
26 changes: 26 additions & 0 deletions jenkins/release.jenkinsFile
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,32 @@ pipeline {
mavenArtifactsPath: "$WORKSPACE/repository/",
autoPublish: true
)

def copyDockerImage = {imageName ->
def registries = ['opensearchproject', 'public.ecr.aws/opensearchproject']
destRegistries.each { destRegistry ->
build job: 'docker-copy',
parameters: [
string(name: 'SOURCE_IMAGE_REGISTRY', value: sourceRegistry),
string(name: 'SOURCE_IMAGE', value: sourceImage),
string(name: 'DESTINATION_IMAGE_REGISTRY', value: destRegistry),
string(name: 'DESTINATION_IMAGE', value: "${imageName}:${tag}")
]

build job: 'docker-copy',
parameters: [
string(name: 'SOURCE_IMAGE_REGISTRY', value: sourceRegistry),
string(name: 'SOURCE_IMAGE', value: sourceImage),
string(name: 'DESTINATION_IMAGE_REGISTRY', value: destRegistry),
string(name: 'DESTINATION_IMAGE', value: "${imageName}:latest")
]
}
}

copyDockerImage('opensearch-migrations-console');
copyDockerImage('opensearch-migrations-traffic-replayer');
copyDockerImage('opensearch-migrations-traffic-capture-proxy');
copyDockerImage('opensearch-migrations-reindex-from-snapshot');
peterzhuamazon marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
Expand Down