diff --git a/.github/script.sh b/.github/script.sh index 90816b27..ac71f3ae 100755 --- a/.github/script.sh +++ b/.github/script.sh @@ -1,8 +1,8 @@ #!/bin/bash -app_name=$1 -image=$2 -namespace=$3 +app_name=nationalparks +image=nationalparks +namespace=manoj-singh8-dev deploy=`oc get deployment $app_name -n $namespace` if [[ "$?" -eq 0 ]]; then diff --git a/.github/workflows/openshift.yml b/.github/workflows/openshift.yml new file mode 100644 index 00000000..9f989288 --- /dev/null +++ b/.github/workflows/openshift.yml @@ -0,0 +1,82 @@ +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 }} + + 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: + # https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows + 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 + + # https://github.com/redhat-actions/s2i-build#readme + - 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 }} + + # https://github.com/redhat-actions/push-to-registry#readme + - name: Push to Registry + id: push-to-registry + uses: redhat-actions/push-to-registry@v2 + with: + image: ${{ steps.build_image.outputs.image }} + tags: ${{ steps.build_image.outputs.tags }} + registry: ${{ env.IMAGE_REGISTRY }} + username: ${{ env.REGISTRY_USER }} + password: ${{ env.REGISTRY_PASSWORD }} + + # The path the image was pushed to is now stored in ${{ steps.push-to-registry.outputs.registry-path }} + + # https://github.com/redhat-actions/oc-login#readme + - 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 }} + + # Run a script to create a new app or update the current one with the previously pushed container image + - run: | + "${GITHUB_WORKSPACE}/.github/script.sh" ${{ env.APP_NAME }} ${{ env.IMAGE_REGISTRY }}/${{ steps.build_image.outputs.image }}:${{ github.sha }} ${{ env.OPENSHIFT_NAMESPACE }} + # Run Prisma Scan IBM Account + - name: Scan image + uses: PaloAltoNetworks/prisma-cloud-scan@v1 + with: + pcc_console_url: ${{ secrets.PCC_CONSOLE_URL }} + pcc_user: ${{ secrets.PCC_USER }} + pcc_pass: ${{ secrets.PCC_PASS }} + image_name: ${{ env.APP_NAME }} diff --git a/PIPELINE.md b/PIPELINE.md index 49e16f21..c35484b2 100644 --- a/PIPELINE.md +++ b/PIPELINE.md @@ -147,3 +147,4 @@ in the same project as Jenkins. This will contain the `master` branch of each pr to each repository will result in a new pipeline getting instantiated and a new project getting created for that pipeline. The GitHub PR will then include a status of the build, a link to the application preview, and a link to the approval page. + diff --git a/README.adoc b/README.adoc index 24c14b92..8e4f4346 100644 --- a/README.adoc +++ b/README.adoc @@ -1,7 +1,9 @@ = NationalParks backend application -This application is a backend that provides geolocation information about NationalParks. The information is stored in a mongodb +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbcccccccccccc +This application is a backend that provides geolocation information about NationalParks. The information is stored in a mongodb +Hello DevD == Installation As the application needs to interact with openshift's API, you'll need to provide some permissions to the default ServiceAccount for that. @@ -30,7 +32,7 @@ There's some options that can be parameterized: * MAVEN_MIRROR_URL: Url of a maven mirror * APPLICATION_HOSTNAME: Hostname/route to access your application -Example: +Example: Hello World Hello World hello word ---- oc new-app nationalparks -p APPLICATION_HOSTNAME=nationalparks-roadshow.127.0.0.1.xip.io -p MAVEN_MIRROR_URL=http://nexus.ci:8081/content/groups/public @@ -41,3 +43,9 @@ oc new-app nationalparks -p APPLICATION_HOSTNAME=nationalparks-roadshow.127.0.0. National Parks data comes from link:https://protectedplanet.net[ProtectedPlanet], listing worldwide National Parks categories, filtered as units shown link:https://en.wikipedia.org/wiki/List_of_the_United_States_National_Park_System_official_units[here] We used this link:https://www.protectedplanet.net/en/search-areas?filters%5Bis_type%5D%5B%5D=terrestrial&filters%5Bdesignation%5D%5B%5D=Nacional+Park&filters%5Bdesignation%5D%5B%5D=National+Forest+Park&filters%5Bdesignation%5D%5B%5D=National+Historic+Park&filters%5Bdesignation%5D%5B%5D=National+Battlefield&filters%5Bdesignation%5D%5B%5D=National+Historic+Site&filters%5Bdesignation%5D%5B%5D=National+Historical+Park&filters%5Bdesignation%5D%5B%5D=National+Lakeshore&filters%5Bdesignation%5D%5B%5D=National+Military+Park&filters%5Bdesignation%5D%5B%5D=National+Monument&filters%5Bdesignation%5D%5B%5D=National+Park&filters%5Bdesignation%5D%5B%5D=National+Park+%28Category+Ii%29&filters%5Bdesignation%5D%5B%5D=National+Park+%28Commonwealth%29&filters%5Bdesignation%5D%5B%5D=National+Park+%28Fbih+Law%29&filters%5Bdesignation%5D%5B%5D=National+Park+%28PN%29&filters%5Bdesignation%5D%5B%5D=National+Park+%28Rs+Law%29&filters%5Bdesignation%5D%5B%5D=National+Park+%28Scientific%29&filters%5Bdesignation%5D%5B%5D=National+Park+%28Svalbard%29&filters%5Bdesignation%5D%5B%5D=National+Park+%28project%29&filters%5Bdesignation%5D%5B%5D=National+Park+-+Buffer+Zone&filters%5Bdesignation%5D%5B%5D=National+Park+-+Buffer+Zone%2FArea+Of+Adhesion&filters%5Bdesignation%5D%5B%5D=National+Park+-+Core+Area&filters%5Bdesignation%5D%5B%5D=National+Park+-+Integrale+Reserve&filters%5Bdesignation%5D%5B%5D=National+Park+-+Peripheral+Zone&filters%5Bdesignation%5D%5B%5D=National+Park+Aboriginal&filters%5Bdesignation%5D%5B%5D=National+Park+and+ASEAN+Heritage+Park&filters%5Bdesignation%5D%5B%5D=National+Park+and+Ecological+Reserve&filters%5Bdesignation%5D%5B%5D=National+Park+and+Indigenous+Territory&filters%5Bdesignation%5D%5B%5D=National+Reserve&filters%5Bdesignation%5D%5B%5D=National+River&filters%5Bdesignation%5D%5B%5D=National+Seashore[query] listing 2830 National Parks at the moment. + +test testing SITA RAM HANUMAN + +Hello Sita Ram Sita Ram +Hello Test +Hello World