diff --git a/.github/workflows/openshift.yml b/.github/workflows/openshift.yml new file mode 100644 index 00000000..71aac2fe --- /dev/null +++ b/.github/workflows/openshift.yml @@ -0,0 +1,70 @@ +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: "matthew29-dev" + + 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-18.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 }} diff --git a/openshift.yml b/openshift.yml new file mode 100644 index 00000000..71aac2fe --- /dev/null +++ b/openshift.yml @@ -0,0 +1,70 @@ +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: "matthew29-dev" + + 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-18.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 }} diff --git a/pipeline/nationalparks-pipeline-all-new.yaml b/pipeline/nationalparks-pipeline-all-new.yaml index 30a2d8d9..40142cf0 100644 --- a/pipeline/nationalparks-pipeline-all-new.yaml +++ b/pipeline/nationalparks-pipeline-all-new.yaml @@ -203,3 +203,5 @@ spec: workspaces: - name: app-source - name: maven-settings + +#Maven proooooooooject \ No newline at end of file diff --git a/src/main/java/com/openshift/evg/roadshow/parks/rest/BackendController.java b/src/main/java/com/openshift/evg/roadshow/parks/rest/BackendController.java index fb0b924b..377c0cee 100644 --- a/src/main/java/com/openshift/evg/roadshow/parks/rest/BackendController.java +++ b/src/main/java/com/openshift/evg/roadshow/parks/rest/BackendController.java @@ -17,6 +17,6 @@ public class BackendController{ @RequestMapping(method = RequestMethod.GET, produces = "application/json") public Backend get() { - return new Backend("nationalparks","National Parks", new Coordinates("47.039304", "14.505178"), 4); + return new Backend("nationalparks","Awesome National Parks", new Coordinates("47.039304", "14.505178"), 4); } }