Skip to content

Commit

Permalink
updating and pulling base image
Browse files Browse the repository at this point in the history
Signed-off-by: Rajpal Chauhan <[email protected]>
  • Loading branch information
rajpalc7 committed Feb 8, 2024
1 parent c459b27 commit 1776a4a
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 23 deletions.
22 changes: 11 additions & 11 deletions .github/workflows/actions/deploy/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ runs:
echo starting rollout in ${{ inputs.namespace }}
oc -n ${{ inputs.namespace }} rollout status dc/${{ inputs.deployment_configuration }} --watch
# - name: Rocket.Chat Notification
# uses: RocketChat/[email protected]
# if: always()
# with:
# type: ${{ job.status }}
# job_name: '*Deployment to ${{ inputs.environment }}*'
# mention: 'here'
# mention_if: 'failure'
# channel: '#ditp-gha-notifications'
# url: ${{ inputs.rocketchat_webhook }}
# commit: true
- name: Rocket.Chat Notification
uses: RocketChat/[email protected]
if: always()
with:
type: ${{ job.status }}
job_name: '*Deployment to ${{ inputs.environment }}*'
mention: 'here'
mention_if: 'failure'
channel: '#ditp-gha-notifications'
url: ${{ inputs.rocketchat_webhook }}
commit: true
50 changes: 38 additions & 12 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflow_dispatch:
inputs:
tag:
description: 'Define the tag for thecode'
description: 'Define the tag for the code'
required: false
branch:
description: 'Define branch name'
Expand Down Expand Up @@ -54,8 +54,12 @@ jobs:
- service: aries-endorser-api
GIT_REPO_URL: hyperledger/aries-endorser-service
DOCKER_FILE_PATH: Dockerfile.endorser # The docker path, file, is the relative path to the docker file from the root of the repo.
SOURCE_CONTEXT_DIR: endorser # The context dir, context, sets the context for the build. i.e. where the build will source files from

SOURCE_CONTEXT_DIR: endorser # The context dir, context, sets the context for the build. i.e. where the build will source files from
BASE_SOURCE_IMAGE_REGISTRY: artifacts.developer.gov.bc.ca/docker-remote/
BASE_SOURCE_IMAGE_NAME: python
BASE_SOURCE_IMAGE_TAG: 3.10-slim-buster
REGISTRY_USERNAME_SECRET_NAME: ARTIFACTORY_USERNAME
REGISTRY_PASSWORD_SECRET_NAME: ARTIFACTORY_PASSWORD
outputs:
aries-endorser-agent_digest: ${{ steps.digest.outputs.aries-endorser-agent_digest }}
aries-endorser-backup_digest: ${{ steps.digest.outputs.aries-endorser-backup_digest }}
Expand All @@ -68,25 +72,29 @@ jobs:
uses: actions/checkout@v4
with:
repository: ${{ matrix.GIT_REPO_URL }}
ref: ${{ github.event.tag }}
ref: ${{ github.event.tag }}
if: ${{ github.event.tag != '' }}

- name: Checkout
uses: actions/checkout@v4
with:
repository: ${{ matrix.GIT_REPO_URL }}
ref: ${{ github.event.branch }}
ref: ${{ github.event.branch }}
if: ${{ github.event.tag == '' }}


- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Pull base image for proxy and Create Docker file
if: contains(fromJSON('["aries-endorser-proxy"]'), matrix.service)
run: |
if [[ -n "${BASE_SOURCE_IMAGE_REGISTRY}" ]]; then
docker login -u $REGISTRY_USERNAME -p $REGISTRY_PASSWORD $BASE_SOURCE_IMAGE_REGISTRY
BASE_IMAGE="${BASE_SOURCE_IMAGE_REGISTRY}${BASE_SOURCE_IMAGE_NAME}:${BASE_SOURCE_IMAGE_TAG}"
else
docker login -u $REGISTRY_USERNAME -p $REGISTRY_PASSWORD $SOURCE_IMAGE_REGISTRY
BASE_IMAGE=${SOURCE_IMAGE_REGISTRY}${SOURCE_IMAGE_NAME}:${SOURCE_IMAGE_TAG}
fi
docker pull "${BASE_IMAGE}"
mkdir ${context} && cd ${context}
echo "FROM ${BASE_IMAGE}" > Dockerfile
Expand All @@ -96,6 +104,9 @@ jobs:
SOURCE_IMAGE_REGISTRY: ${{ matrix.SOURCE_IMAGE_REGISTRY }}
SOURCE_IMAGE_NAME: ${{ matrix.SOURCE_IMAGE_NAME }}
SOURCE_IMAGE_TAG: ${{ matrix.SOURCE_IMAGE_TAG }}
BASE_SOURCE_IMAGE_REGISTRY: ${{ matrix.BASE_SOURCE_IMAGE_REGISTRY }}
BASE_SOURCE_IMAGE_NAME: ${{ matrix.BASE_SOURCE_IMAGE_NAME }}
BASE_SOURCE_IMAGE_TAG: ${{ matrix.BASE_SOURCE_IMAGE_TAG }}
REGISTRY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
REGISTRY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}

Expand All @@ -122,7 +133,25 @@ jobs:
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha,value=latest
- name: Update Docker base image and pull the base image if access is required
if: matrix.BASE_SOURCE_IMAGE_REGISTRY != '' && contains(fromJSON('["aries-endorser-db","aries-endorser-agent","aries-endorser-backup","aries-endorser-api","aries-endorser-proxy"]'), matrix.service)
run: |
if [[ -n "${REGISTRY_USERNAME}" ]]; then
docker login -u $REGISTRY_USERNAME -p $REGISTRY_PASSWORD $BASE_SOURCE_IMAGE_REGISTRY
fi
BASE_IMAGE="${BASE_SOURCE_IMAGE_REGISTRY}${BASE_SOURCE_IMAGE_NAME}:${BASE_SOURCE_IMAGE_TAG}"
sed -i -e "s;FROM .*;FROM ${BASE_IMAGE};g" "$file"
docker pull $BASE_IMAGE
env:
context: ${{ matrix.SOURCE_CONTEXT_DIR }}
BASE_SOURCE_IMAGE_REGISTRY: ${{ matrix.BASE_SOURCE_IMAGE_REGISTRY }}
BASE_SOURCE_IMAGE_NAME: ${{ matrix.BASE_SOURCE_IMAGE_NAME }}
BASE_SOURCE_IMAGE_TAG: ${{ matrix.BASE_SOURCE_IMAGE_TAG }}
file: ${{ matrix.SOURCE_CONTEXT_DIR }}/${{ matrix.DOCKER_FILE_PATH }}
REGISTRY_USERNAME: ${{ secrets[matrix.REGISTRY_USERNAME_SECRET_NAME]}}
REGISTRY_PASSWORD: ${{ secrets[matrix.REGISTRY_PASSWORD_SECRET_NAME]}}

- name: Build and push Docker image
id: docker_build
if: contains(fromJSON('["aries-endorser-agent","aries-endorser-backup","aries-endorser-api","aries-endorser-proxy"]'), matrix.service)
Expand Down Expand Up @@ -185,10 +214,7 @@ jobs:
echo 'digest=${digest}'
echo "${{ matrix.service }}_digest=${digest}" >> $GITHUB_OUTPUT
cat $GITHUB_OUTPUT
<<<<<<< HEAD

=======
>>>>>>> 75dd3452af8946bd6347ac3909ed344649da182c
deploy2dev:
needs: build
env:
Expand Down Expand Up @@ -224,7 +250,7 @@ jobs:
namespace: ${{ vars.NAMESPACE }}
deployment_configuration: ${{ matrix.service }}
openshift_token: ${{ secrets.OPENSHIFT_TOKEN }}
# rocketchat_webhook: ${{ secrets.ROCKETCHAT_WEBHOOK }}
rocketchat_webhook: ${{ secrets.ROCKETCHAT_WEBHOOK }}

# docker pull ghcr.io/bcgov/dts-endorser-service@sha256:57f946ab1053726ac6fcb71c85a98d355e926904ebe26db4798353668b3f6c68

Expand Down

0 comments on commit 1776a4a

Please sign in to comment.