Skip to content

Commit

Permalink
Adding labels to endorser-db to match other services
Browse files Browse the repository at this point in the history
Signed-off-by: Rajpal Chauhan <[email protected]>
  • Loading branch information
rajpalc7 committed Mar 8, 2024
1 parent c7f4a0e commit 0147524
Show file tree
Hide file tree
Showing 2 changed files with 430 additions and 0 deletions.
113 changes: 113 additions & 0 deletions .github/workflows/actions/deploy/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
name: Deploy
description: Deploy to OpenShift namespace

inputs:
environment:
description: The environment to which the image will be deployed.
required: true

# Image parameters
ghcr_token:
description: The token to use to login to the GHCR.
required: true
github_image_name:
description: The name of the image in the GHCR to be deployed.
required: true
image_digest:
description: The digest of the image to be deployed. Identifies the unique image tag in the GHCR.
required: true
openshift_image_name:
description: The name of the image to use when pushing to OpenShift.
required: true

# OpenShift parameters
openshift_server_url:
description: The URL of the OpenShift server.
required: true
namespace:
description: The OpenShift namespace where the image is to be deployed.
required: true
deployment_configuration:
description: The name of the OpenShift deployment configuration triggered by the new image.
required: true
openshift_token:
description: The token used to authenticate with the OpenShift server.
required: true

# rocket.chat notification parameters
rocketchat_webhook:
description: The URL to use for posting notifications to rocket.chat.
required: true

runs:
using: composite
steps:
- name: Log in to the GHCR
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ inputs.ghcr_token }}

- name: Setup Openshift CLI
uses: redhat-actions/oc-login@v1
with:
openshift_server_url: ${{ inputs.openshift_server_url }}
openshift_token: ${{ inputs.openshift_token }}

- name: Login in to OpenShift container registry
shell: bash
env:
REGISTRY_AUTH_PREFERENCE: docker
run: |
oc version
docker version
# Openshift pipeline is currently running on 14.4.6 version and according to
# the new red hat article - https://access.redhat.com/articles/7042033
# the Podman auth configuration locations are preferred over Docker configuration locations.
# In order to avoid the "unauthorized: authentication required error" and
# make github actions job run successfully make sure when we try to login to openshift registry
# we need to define the oc registry login --to="${HOME}/.docker/config.json" in the oc login action step.
# This was not an issue when Openshift pipeline was running on 14.2 or 14.3 version
# but since Openshift upgraded to 14.4 version it started giving warning
# message : the default reading order of registry auth file will be changed from "${HOME}/.docker/config.json"
# to podman registry config locations in the future version of oc.
# "${HOME}/.docker/config.json" is deprecated, but can still be used for storing credentials
# as a fallback. See https://github.com/containers/image/blob/main/docs/containers-auth.json.5.md for the order
# of podman registry config locations.
oc registry login --to="${HOME}/.docker/config.json"
- name: Tag the image in the GHCR as ${{ inputs.environment }}
shell: bash
run: |
docker pull ${{ inputs.github_image_name }}@${{ inputs.image_digest }}
docker tag ${{ inputs.github_image_name }}@${{ inputs.image_digest }} ${{ inputs.github_image_name }}:${{ inputs.environment }}
docker push ${{ inputs.github_image_name }}:${{ inputs.environment }}
- name: Tag the image in the OpenShift container registry as ${{ inputs.environment }}
shell: bash
run: |
docker pull ${{ inputs.github_image_name }}@${{ inputs.image_digest }}
docker tag ${{ inputs.github_image_name }}@${{ inputs.image_digest }} ${{ inputs.openshift_image_name }}:${{ inputs.environment }}
docker push ${{ inputs.openshift_image_name}}:${{ inputs.environment }}
- name: Trigger OpenShift rollout
shell: bash
run: |
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
Loading

0 comments on commit 0147524

Please sign in to comment.