From aff449d16b4b5f6fbc260e4b0d2b60fe1bf34cfc Mon Sep 17 00:00:00 2001 From: Michael Valdron Date: Fri, 21 Oct 2022 17:13:04 -0400 Subject: [PATCH 01/11] registry viewer shell build scripts added. Signed-off-by: Michael Valdron --- scripts/build_viewer.sh | 6 ++++++ scripts/push.sh | 6 ++++++ 2 files changed, 12 insertions(+) create mode 100644 scripts/build_viewer.sh create mode 100644 scripts/push.sh diff --git a/scripts/build_viewer.sh b/scripts/build_viewer.sh new file mode 100644 index 00000000..e42c619f --- /dev/null +++ b/scripts/build_viewer.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +docker build -t registry-viewer . \ + --build-arg PROJECT_NAME=registry-viewer \ + --build-arg NEXT_PUBLIC_BASE_PATH=/viewer \ + --build-arg NEXT_PUBLIC_ANALYTICS_WRITE_KEY=${NEXT_PUBLIC_ANALYTICS_WRITE_KEY:-""} diff --git a/scripts/push.sh b/scripts/push.sh new file mode 100644 index 00000000..4bd84eb3 --- /dev/null +++ b/scripts/push.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +BASE_TAG=$1 +IMAGE_TAG=$2 +docker tag $BASE_TAG $IMAGE_TAG +docker push $IMAGE_TAG From e5b1c3036e73abfe52f766dced017649c001a8be Mon Sep 17 00:00:00 2001 From: Michael Valdron Date: Fri, 21 Oct 2022 17:13:48 -0400 Subject: [PATCH 02/11] registry viewer build and push image workflow added. Signed-off-by: Michael Valdron --- .github/workflows/pushimage-next.yml | 57 ++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 .github/workflows/pushimage-next.yml diff --git a/.github/workflows/pushimage-next.yml b/.github/workflows/pushimage-next.yml new file mode 100644 index 00000000..2522dba8 --- /dev/null +++ b/.github/workflows/pushimage-next.yml @@ -0,0 +1,57 @@ +# +# Copyright 2020-2022 Red Hat, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: Next Dockerimage + +on: + push: + branches: [main] + repository_dispatch: + types: [build] + +jobs: + registryViewerBuild: + runs-on: ubuntu-latest + steps: + - name: Check out devfile web source code + uses: actions/checkout@v3 + - name: Login to Quay + uses: docker/login-action@v1 + with: + registry: quay.io + username: ${{ secrets.QUAY_USERNAME }} + password: ${{ secrets.QUAY_PASSWORD }} + - name: Build the registry viewer image + run: | + docker build -t registry-viewer . \ + --build-arg PROJECT_NAME=registry-viewer \ + --build-arg NEXT_PUBLIC_BASE_PATH=/viewer \ + --build-arg NEXT_PUBLIC_ANALYTICS_WRITE_KEY=${{ secrets.NEXT_PUBLIC_ANALYTICS_WRITE_KEY }} + - name: Push the registry viewer image + run: bash ./scripts/push.sh registry-viewer:latest quay.io/devfile/registry-viewer:next + dispatch: + needs: registryViewerBuild + strategy: + matrix: + repo: ['devfile/registry'] + runs-on: ubuntu-latest + steps: + - name: Repository dispatch + uses: peter-evans/repository-dispatch@v1 + with: + token: ${{ secrets.REPO_ACCESS_TOKEN }} + repository: ${{ matrix.repo }} + event-type: build + client-payload: '{"repo": "${{ github.event.repository.name }}", "sha": "${{ github.sha }}"}' From 1059e9e536ea8d87c76b0ce7c7f361727b8a6653 Mon Sep 17 00:00:00 2001 From: Michael Valdron Date: Mon, 24 Oct 2022 13:38:39 -0400 Subject: [PATCH 03/11] NEXT_PUBLIC_DEVFILE_REGISTRIES env variable added to build scripts and CI. Push image workflow uses build_viewer.sh script for building the docker image. Signed-off-by: Michael Valdron --- .github/workflows/pushimage-next.yml | 15 ++++++++++----- scripts/build_viewer.sh | 7 ++++--- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/.github/workflows/pushimage-next.yml b/.github/workflows/pushimage-next.yml index 2522dba8..cc2df6f7 100644 --- a/.github/workflows/pushimage-next.yml +++ b/.github/workflows/pushimage-next.yml @@ -24,6 +24,15 @@ on: jobs: registryViewerBuild: runs-on: ubuntu-latest + env: + NEXT_PUBLIC_DEVFILE_REGISTRIES: | + [ + { + "name": "Community", + "link": "https://registry.devfile.io/" + } + ] + NEXT_PUBLIC_ANALYTICS_WRITE_KEY: ${{ secrets.NEXT_PUBLIC_ANALYTICS_WRITE_KEY }} steps: - name: Check out devfile web source code uses: actions/checkout@v3 @@ -34,11 +43,7 @@ jobs: username: ${{ secrets.QUAY_USERNAME }} password: ${{ secrets.QUAY_PASSWORD }} - name: Build the registry viewer image - run: | - docker build -t registry-viewer . \ - --build-arg PROJECT_NAME=registry-viewer \ - --build-arg NEXT_PUBLIC_BASE_PATH=/viewer \ - --build-arg NEXT_PUBLIC_ANALYTICS_WRITE_KEY=${{ secrets.NEXT_PUBLIC_ANALYTICS_WRITE_KEY }} + run: bash ./scripts/build_viewer.sh - name: Push the registry viewer image run: bash ./scripts/push.sh registry-viewer:latest quay.io/devfile/registry-viewer:next dispatch: diff --git a/scripts/build_viewer.sh b/scripts/build_viewer.sh index e42c619f..2157babb 100644 --- a/scripts/build_viewer.sh +++ b/scripts/build_viewer.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash docker build -t registry-viewer . \ - --build-arg PROJECT_NAME=registry-viewer \ - --build-arg NEXT_PUBLIC_BASE_PATH=/viewer \ - --build-arg NEXT_PUBLIC_ANALYTICS_WRITE_KEY=${NEXT_PUBLIC_ANALYTICS_WRITE_KEY:-""} + --build-arg PROJECT_NAME=registry-viewer \ + --build-arg NEXT_PUBLIC_BASE_PATH=/viewer \ + --build-arg NEXT_PUBLIC_DEVFILE_REGISTRIES="${NEXT_PUBLIC_DEVFILE_REGISTRIES:-""}" \ + --build-arg NEXT_PUBLIC_ANALYTICS_WRITE_KEY=${NEXT_PUBLIC_ANALYTICS_WRITE_KEY:-""} From 4e7696c5ee5af1fff2be81f210a47b0107bbb8bf Mon Sep 17 00:00:00 2001 From: Michael Valdron Date: Mon, 24 Oct 2022 14:03:34 -0400 Subject: [PATCH 04/11] license fixups. Signed-off-by: Michael Valdron --- .github/workflows/pushimage-next.yml | 19 +++++++++---------- scripts/build_viewer.sh | 14 ++++++++++++++ scripts/docs.sh | 14 ++++++++++++++ scripts/push.sh | 14 ++++++++++++++ 4 files changed, 51 insertions(+), 10 deletions(-) diff --git a/.github/workflows/pushimage-next.yml b/.github/workflows/pushimage-next.yml index cc2df6f7..f153f509 100644 --- a/.github/workflows/pushimage-next.yml +++ b/.github/workflows/pushimage-next.yml @@ -1,17 +1,16 @@ +# Copyright 2022 Red Hat, Inc. # -# Copyright 2020-2022 Red Hat, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. name: Next Dockerimage diff --git a/scripts/build_viewer.sh b/scripts/build_viewer.sh index 2157babb..ba154bc3 100644 --- a/scripts/build_viewer.sh +++ b/scripts/build_viewer.sh @@ -1,3 +1,17 @@ +# Copyright 2022 Red Hat, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + #!/usr/bin/env bash docker build -t registry-viewer . \ diff --git a/scripts/docs.sh b/scripts/docs.sh index 6e53d716..74083ecb 100755 --- a/scripts/docs.sh +++ b/scripts/docs.sh @@ -1,3 +1,17 @@ +# Copyright 2022 Red Hat, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + #!/usr/bin/env bash chmod +x ./dist/libs/docs/src/scripts/index.js diff --git a/scripts/push.sh b/scripts/push.sh index 4bd84eb3..b3a764ef 100644 --- a/scripts/push.sh +++ b/scripts/push.sh @@ -1,3 +1,17 @@ +# Copyright 2022 Red Hat, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + #!/usr/bin/env bash BASE_TAG=$1 From 01da7e566bbbddb80ba2dcb838d5472be0f23188 Mon Sep 17 00:00:00 2001 From: Michael Valdron Date: Mon, 24 Oct 2022 14:26:31 -0400 Subject: [PATCH 05/11] Push image workflow can be trigged by external dispatch. Signed-off-by: Michael Valdron --- .github/workflows/pushimage-next.yml | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pushimage-next.yml b/.github/workflows/pushimage-next.yml index f153f509..dcdb565d 100644 --- a/.github/workflows/pushimage-next.yml +++ b/.github/workflows/pushimage-next.yml @@ -52,10 +52,33 @@ jobs: repo: ['devfile/registry'] runs-on: ubuntu-latest steps: + - name: Get the repository name and commit sha + id: get_commit_info + run: | + # Check if repository name is not set in the client payload + # If it's not set, the triggered commit came from this repo (devfile-web) + # If it is set, the triggered commit came from another source + if [ -z ${{ github.event.client_payload.repo }} ]; + then + echo ::set-output name=repo::$(echo ${{ github.event.repository.name }}) + else + echo ::set-output name=repo::$(echo ${{ github.event.client_payload.repo }}) + fi + + # Check if commit sha is not set in the client payload + # If it's not set, the triggered commit came from this repo (devfile-web) + # If it is set, the triggered commit came from another source + + if [ -z ${{ github.event.client_payload.sha }} ]; + then + echo ::set-output name=sha::$(echo ${{ github.sha }}) + else + echo ::set-output name=sha::$(echo ${{ github.event.client_payload.sha }}) + fi - name: Repository dispatch uses: peter-evans/repository-dispatch@v1 with: token: ${{ secrets.REPO_ACCESS_TOKEN }} repository: ${{ matrix.repo }} event-type: build - client-payload: '{"repo": "${{ github.event.repository.name }}", "sha": "${{ github.sha }}"}' + client-payload: '{"repo": "${{ steps.get_commit_info.outputs.REPO }}", "sha": "${{ steps.get_commit_info.outputs.SHA }}"}' From 06c5fe68569f39444bc1c89dc6481b47d73fe14f Mon Sep 17 00:00:00 2001 From: Michael Valdron Date: Mon, 24 Oct 2022 14:43:35 -0400 Subject: [PATCH 06/11] license header added to Dockerfile. Signed-off-by: Michael Valdron --- Dockerfile | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Dockerfile b/Dockerfile index 0fd4b7db..4b0f5635 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,16 @@ +# Copyright 2022 Red Hat, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. # Install dependencies only when needed FROM registry.access.redhat.com/ubi8/nodejs-16-minimal AS deps From 014e53610e09857ad0b2bd6647c92bf573c4b2cc Mon Sep 17 00:00:00 2001 From: Michael Valdron Date: Mon, 24 Oct 2022 15:15:12 -0400 Subject: [PATCH 07/11] quay.io/devfile/registry-viewer:next is built from staging. Signed-off-by: Michael Valdron --- .github/workflows/pushimage-next.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/pushimage-next.yml b/.github/workflows/pushimage-next.yml index dcdb565d..4d1c1841 100644 --- a/.github/workflows/pushimage-next.yml +++ b/.github/workflows/pushimage-next.yml @@ -24,13 +24,6 @@ jobs: registryViewerBuild: runs-on: ubuntu-latest env: - NEXT_PUBLIC_DEVFILE_REGISTRIES: | - [ - { - "name": "Community", - "link": "https://registry.devfile.io/" - } - ] NEXT_PUBLIC_ANALYTICS_WRITE_KEY: ${{ secrets.NEXT_PUBLIC_ANALYTICS_WRITE_KEY }} steps: - name: Check out devfile web source code From 070b25b1556624a758e38c8797b9c5352085b2b2 Mon Sep 17 00:00:00 2001 From: Michael Valdron Date: Fri, 28 Oct 2022 15:48:18 -0400 Subject: [PATCH 08/11] build args for registry viewer changed to match recent changes to Dockerfile. Signed-off-by: Michael Valdron --- scripts/build_viewer.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/build_viewer.sh b/scripts/build_viewer.sh index ba154bc3..41c3d087 100644 --- a/scripts/build_viewer.sh +++ b/scripts/build_viewer.sh @@ -16,6 +16,6 @@ docker build -t registry-viewer . \ --build-arg PROJECT_NAME=registry-viewer \ - --build-arg NEXT_PUBLIC_BASE_PATH=/viewer \ - --build-arg NEXT_PUBLIC_DEVFILE_REGISTRIES="${NEXT_PUBLIC_DEVFILE_REGISTRIES:-""}" \ + --build-arg SITE_URL=${SITE_URL:-"https://registry.stage.devfile.io/viewer"} \ + --build-arg NEXT_PUBLIC_BASE_PATH=${NEXT_PUBLIC_BASE_PATH:-"/viewer"} \ --build-arg NEXT_PUBLIC_ANALYTICS_WRITE_KEY=${NEXT_PUBLIC_ANALYTICS_WRITE_KEY:-""} From 2d44deb656f9fc950e93abfd052d7be4c6243b0d Mon Sep 17 00:00:00 2001 From: Michael Valdron Date: Mon, 31 Oct 2022 13:59:19 -0400 Subject: [PATCH 09/11] registryViewerBuild job renamed to registry-viewer-build, label named 'Registry Viewer Build'. Signed-off-by: Michael Valdron --- .github/workflows/pushimage-next.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pushimage-next.yml b/.github/workflows/pushimage-next.yml index 4d1c1841..bd89e0aa 100644 --- a/.github/workflows/pushimage-next.yml +++ b/.github/workflows/pushimage-next.yml @@ -21,7 +21,8 @@ on: types: [build] jobs: - registryViewerBuild: + registry-viewer-build: + name: Registry Viewer Build runs-on: ubuntu-latest env: NEXT_PUBLIC_ANALYTICS_WRITE_KEY: ${{ secrets.NEXT_PUBLIC_ANALYTICS_WRITE_KEY }} @@ -39,7 +40,7 @@ jobs: - name: Push the registry viewer image run: bash ./scripts/push.sh registry-viewer:latest quay.io/devfile/registry-viewer:next dispatch: - needs: registryViewerBuild + needs: registry-viewer-build strategy: matrix: repo: ['devfile/registry'] From c628a6363d0bde4c3f73b3fb88261df841ad0ba2 Mon Sep 17 00:00:00 2001 From: Michael Valdron Date: Mon, 31 Oct 2022 14:00:09 -0400 Subject: [PATCH 10/11] concurrency options added to pushimage-next Signed-off-by: Michael Valdron --- .github/workflows/pushimage-next.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/pushimage-next.yml b/.github/workflows/pushimage-next.yml index bd89e0aa..194f9972 100644 --- a/.github/workflows/pushimage-next.yml +++ b/.github/workflows/pushimage-next.yml @@ -20,6 +20,10 @@ on: repository_dispatch: types: [build] +concurrency: + group: ${{ github.workflow }}-${{ github.event.number || github.ref }} + cancel-in-progress: true + jobs: registry-viewer-build: name: Registry Viewer Build From c8fcb60bd3fd8323006c6cdfbc8cb2d89b416cd3 Mon Sep 17 00:00:00 2001 From: Michael Valdron Date: Mon, 31 Oct 2022 14:18:44 -0400 Subject: [PATCH 11/11] NEXT_PUBLIC_ANALYTICS_WRITE_KEY removed as a secret. Signed-off-by: Michael Valdron --- .github/workflows/pushimage-next.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/pushimage-next.yml b/.github/workflows/pushimage-next.yml index 194f9972..31129022 100644 --- a/.github/workflows/pushimage-next.yml +++ b/.github/workflows/pushimage-next.yml @@ -28,8 +28,6 @@ jobs: registry-viewer-build: name: Registry Viewer Build runs-on: ubuntu-latest - env: - NEXT_PUBLIC_ANALYTICS_WRITE_KEY: ${{ secrets.NEXT_PUBLIC_ANALYTICS_WRITE_KEY }} steps: - name: Check out devfile web source code uses: actions/checkout@v3