Skip to content

Commit

Permalink
Merge pull request #3 from catenax-ng/main
Browse files Browse the repository at this point in the history
feat!: Merge upstream v1.0.0
  • Loading branch information
evegufy authored Feb 23, 2023
2 parents 9332a69 + ef21d79 commit 446421b
Show file tree
Hide file tree
Showing 310 changed files with 28,290 additions and 2 deletions.
47 changes: 47 additions & 0 deletions .conf/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
###############################################################
# Copyright (c) 2021, 2023 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License, Version 2.0 which is available at
# https://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.
#
# SPDX-License-Identifier: Apache-2.0
###############################################################

#
# usage:
# export NAME=tx-portal-assets
# export IMAGE=ghcr.io/catenax-ng/$NAME
# docker build -t $IMAGE -f .conf/Dockerfile .
# docker run --rm -d -p 3000:8080 --name $NAME $IMAGE
# docker exec $NAME find /usr/share/nginx/html/
# docker stop $NAME
# docker push $IMAGE
#

# Step 1
FROM alpine:3.17 as build-step
COPY public /public
WORKDIR /public/assets
RUN find . -type f | cut -c 3- | sort > index.txt
WORKDIR /public/documentation
RUN find . -type f | cut -c 3- | sort > index.txt

# Step 2
FROM nginxinc/nginx-unprivileged:alpine
# temp fix for CVE-2023-0286
USER root
RUN apk upgrade --no-cache libssl3 libcrypto3
COPY .conf/nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=build-step /public/assets /usr/share/nginx/html/assets
COPY --from=build-step /public/documentation /usr/share/nginx/html/documentation
USER 101
30 changes: 30 additions & 0 deletions .conf/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
###############################################################
# Copyright (c) 2021, 2023 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License, Version 2.0 which is available at
# https://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.
#
# SPDX-License-Identifier: Apache-2.0
###############################################################

server {

listen 8080;
server_name localhost;

location / {
root /usr/share/nginx/html;
index index.html;
}

}
96 changes: 96 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
###############################################################
# Copyright (c) 2021, 2023 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License, Version 2.0 which is available at
# https://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.
#
# SPDX-License-Identifier: Apache-2.0
###############################################################

name: build

on:
push:
branches:
- 'main'

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
COMMIT_SHA: ${{ github.sha }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Install Dependencies
run: yarn

- name: Build Library and Portal
run: yarn build

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract Metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: .
file: .conf/Dockerfile
push: true
# build tag :main with commit-sha and latest
tags: ${{ steps.meta.outputs.tags }}_${{ env.COMMIT_SHA }}, ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
labels: ${{ steps.meta.outputs.labels }}

auth-and-dispatch:
needs: build-and-push-image
runs-on: ubuntu-latest

steps:
- name: Get token
id: get_workflow_token
uses: peter-murray/workflow-application-token-action@v1
with:
application_id: ${{ secrets.ORG_PORTAL_DISPATCH_APPID }}
application_private_key: ${{ secrets.ORG_PORTAL_DISPATCH_KEY }}

# The triggered workflow isn't enabled for branch names / github.ref_name containing special characters like '/' for example 'feature/...'
- name: Trigger workflow
id: call_action
env:
TOKEN: ${{ steps.get_workflow_token.outputs.token }}
run: |
curl -v \
--request POST \
--url https://api.github.com/repos/catenax-ng/tx-portal-cd/actions/workflows/portal-assets-image-update.yml/dispatches \
--header "authorization: Bearer $TOKEN" \
--header "Accept: application/vnd.github.v3+json" \
--data '{"ref":"helm-environments", "inputs": { "new-image":"${{ github.ref_name }}_${{ env.COMMIT_SHA }}" }}' \
--fail
71 changes: 71 additions & 0 deletions .github/workflows/kics.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
###############################################################
# Copyright (c) 2021, 2023 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License, Version 2.0 which is available at
# https://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.
#
# SPDX-License-Identifier: Apache-2.0
###############################################################

name: "KICS"

on:
push:
branches: [main, master]
# pull_request:
# The branches below must be a subset of the branches above
# branches: [main, master]
# paths-ignore:
# - "**/*.md"
# - "**/*.txt"
schedule:
- cron: "0 0 * * *"

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

steps:
- uses: actions/checkout@v3

- name: KICS scan
uses: checkmarx/kics-github-action@master
with:
# Scanning directory .
path: "."
# Fail on HIGH severity results
fail_on: high
# when provided with a directory on output_path
# it will generate the specified reports file named 'results.{extension}'
# in this example it will generate:
# - results-dir/results.json
# - results-dir/results.sarif
output_path: kicsResults/
output_formats: "json,sarif"
# If you want KICS to ignore the results and return exit status code 0 unless a KICS engine error happens
# ignore_on_exit: results
# GITHUB_TOKEN enables this github action to access github API and post comments in a pull request
# token: ${{ secrets.GITHUB_TOKEN }}
# enable_comments: true

# Upload findings to GitHub Advanced Security Dashboard
- name: Upload SARIF file for GitHub Advanced Security Dashboard
if: always()
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: kicsResults/results.sarif
110 changes: 110 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
###############################################################
# Copyright (c) 2021, 2023 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License, Version 2.0 which is available at
# https://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.
#
# SPDX-License-Identifier: Apache-2.0
###############################################################

name: release

on:
push:
tags:
- '*'

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-release:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Get tag name
id: git-tag
run: echo ::set-output name=git-version::${GITHUB_REF/refs\/tags\//}

- name: Checkout repository
uses: actions/checkout@v3
with:
ref: ${{ steps.git-tag.outputs.git-version }}

- name: Output versions
run: echo building relase from git ${{ steps.git-tag.outputs.git-version }}

- name: Install Dependencies
run: yarn

- name: Build Library and Portal
run: yarn build

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract Metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: .
file: .conf/Dockerfile
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.git-tag.outputs.git-version }}
labels: ${{ steps.meta.outputs.labels }}

auth-and-dispatch:
needs: build-and-push-release
runs-on: ubuntu-latest

steps:

- name: Get tag name
id: git-tag
run: echo ::set-output name=git-version::${GITHUB_REF/refs\/tags\//}

- name: Set env
run: echo "RELEASE_VERSION=${{ steps.git-tag.outputs.git-version }}" >> $GITHUB_ENV

- name: Get token
id: get_workflow_token
uses: peter-murray/workflow-application-token-action@v1
with:
application_id: ${{ secrets.ORG_PORTAL_DISPATCH_APPID }}
application_private_key: ${{ secrets.ORG_PORTAL_DISPATCH_KEY }}

- name: Trigger workflow
id: call_action
env:
TOKEN: ${{ steps.get_workflow_token.outputs.token }}
run: |
curl -v \
--request POST \
--url https://api.github.com/repos/catenax-ng/tx-portal-cd/actions/workflows/portal-assets-int-release-image-update.yml/dispatches \
--header "authorization: Bearer $TOKEN" \
--header "Accept: application/vnd.github.v3+json" \
--data '{"ref":"helm-environments", "inputs": { "new-image":"${{ env.RELEASE_VERSION }}" }}' \
--fail
Loading

0 comments on commit 446421b

Please sign in to comment.