manoj pull update #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: OpenShift | ||
env: | ||
IMAGE_REGISTRY: ghcr.io/${{ github.repository_owner }} | ||
REGISTRY_USER: ${{ github.actor }} | ||
REGISTRY_PASSWORD: ${{ github.token }} | ||
APP_NAME: nationalparks | ||
IMAGE_TAGS: latest,${{ github.sha }} # No change needed here, but ensure commas are properly used in the push step | ||
OPENSHIFT_SERVER: ${{ secrets.OPENSHIFT_SERVER }} | ||
OPENSHIFT_TOKEN: ${{ secrets.OPENSHIFT_TOKEN }} | ||
OPENSHIFT_NAMESPACE: "manoj-singh8-dev" | ||
pcc_console_url: ${{ secrets.PCC_CONSOLE_URL }} | ||
pcc_user: ${{ secrets.PCC_USER }} | ||
pcc_pass: ${{ secrets.PCC_PASS }} | ||
APP_PORT: "8080" | ||
on: | ||
push: | ||
branches: [ master ] | ||
jobs: | ||
build-and-push: | ||
name: Build and push to GitHub container registry | ||
runs-on: ubuntu-22.04 | ||
environment: development | ||
outputs: | ||
ROUTE: ${{ steps.deploy-and-expose.outputs.route }} | ||
SELECTOR: ${{ steps.deploy-and-expose.outputs.selector }} | ||
steps: | ||
- name: Checkout | ||
id: checkout | ||
uses: actions/checkout@v2 | ||
# Build the image using Source-to-Image (S2I) | ||
- name: S2I Build | ||
id: build_image | ||
uses: redhat-actions/s2i-build@v2 | ||
with: | ||
path_context: '.' | ||
builder_image: 'registry.access.redhat.com/ubi8/openjdk-11' | ||
image: ${{ env.APP_NAME }} | ||
tags: ${{ env.IMAGE_TAGS }} | ||
# Push the image to GitHub Container Registry | ||
- name: Push to registry | ||
uses: redhat-actions/push-to-registry@v2 | ||
with: | ||
image: "ghcr.io/devopscicd17/nationalparks" | ||
tag: "latest-$(git rev-parse --short HEAD)" | ||
# Log in to OpenShift | ||
- name: Log in to OpenShift | ||
uses: redhat-actions/oc-login@v1 | ||
with: | ||
openshift_server_url: ${{ env.OPENSHIFT_SERVER }} | ||
openshift_token: ${{ env.OPENSHIFT_TOKEN }} | ||
insecure_skip_tls_verify: true | ||
namespace: ${{ env.OPENSHIFT_NAMESPACE }} | ||
# Deploy or update the application in OpenShift | ||
- name: Deploy to OpenShift | ||
run: | | ||
bash "${GITHUB_WORKSPACE}/.github/script.sh" \ | ||
${{ env.APP_NAME }} \ | ||
${{ env.IMAGE_REGISTRY }}/${{ steps.build_image.outputs.image }}:${{ github.sha }} \ | ||
${{ env.OPENSHIFT_NAMESPACE }} | ||
# Run Prisma Cloud Scan | ||
- name: Scan image | ||
uses: PaloAltoNetworks/prisma-cloud-scan@v1 | ||
with: | ||
pcc_console_url: ${{ env.pcc_console_url }} | ||
pcc_user: ${{ env.pcc_user }} | ||
pcc_pass: ${{ env.pcc_pass }} | ||
image_name: ${{ env.IMAGE_REGISTRY }}/${{ env.APP_NAME }}:${{ github.sha }} |