Skip to content

Commit

Permalink
Merge pull request #860 from peterzhuamazon/migrations-release-docker
Browse files Browse the repository at this point in the history
Update Release Drafter and Jenkinsfile with Docker credentials and promotions
  • Loading branch information
AndreKurait committed Aug 6, 2024
2 parents d8b4b8f + 4f44062 commit 81361f8
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 11 deletions.
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');
}
}
}
Expand Down

0 comments on commit 81361f8

Please sign in to comment.