|
| 1 | +#!/usr/bin/env sh |
| 2 | + |
| 3 | +## %CopyrightBegin% |
| 4 | +## |
| 5 | +## SPDX-License-Identifier: Apache-2.0 |
| 6 | +## |
| 7 | +## Copyright Ericsson AB 2026. All Rights Reserved. |
| 8 | +## |
| 9 | +## Licensed under the Apache License, Version 2.0 (the "License"); |
| 10 | +## you may not use this file except in compliance with the License. |
| 11 | +## You may obtain a copy of the License at |
| 12 | +## |
| 13 | +## http://www.apache.org/licenses/LICENSE-2.0 |
| 14 | +## |
| 15 | +## Unless required by applicable law or agreed to in writing, software |
| 16 | +## distributed under the License is distributed on an "AS IS" BASIS, |
| 17 | +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 18 | +## See the License for the specific language governing permissions and |
| 19 | +## limitations under the License. |
| 20 | +## |
| 21 | +## %CopyrightEnd% |
| 22 | + |
| 23 | + |
| 24 | +REPO=$1 |
| 25 | +BRANCH_NAME=$2 |
| 26 | +# Fetch PR data using gh CLI |
| 27 | +PR_STATUS=$(gh pr view "$BRANCH_NAME" --repo "$REPO" --json state -q ".state") |
| 28 | +FOUND_PR=$? |
| 29 | + |
| 30 | +if [ "$FOUND_PR" -ne 0 ]; then |
| 31 | + echo "No PR with name #$BRANCH_NAME in $REPO exists." |
| 32 | + echo "A new PR will be created" |
| 33 | +fi |
| 34 | + |
| 35 | +# Check if PR is closed |
| 36 | +if [ "$PR_STATUS" = "CLOSED" ] || [ "$PR_STATUS" = "MERGED" ] || [ "$FOUND_PR" -ne 0 ]; then |
| 37 | + echo "Pull request #$BRANCH_NAME is CLOSED or MERGED." |
| 38 | + echo "✅ A new pull request with name #$BRANCH_NAME will be created." |
| 39 | + git branch "$BRANCH_NAME" master |
| 40 | + git checkout "$BRANCH_NAME" |
| 41 | + git add make/openvex.table |
| 42 | + git add vex |
| 43 | + git commit -m "Automatic update of OpenVEX Statements for erlang/otp" |
| 44 | + git push --force origin "$BRANCH_NAME" |
| 45 | + gh pr create --repo "$REPO" -B master \ |
| 46 | + --title "Automatic update of OpenVEX Statements for erlang/otp" \ |
| 47 | + --body "Automatic Action. There is a vulnerability from GH Advisories without a matching OpenVEX statement" |
| 48 | + exit 0 |
| 49 | +else |
| 50 | + echo "❌ Pull request #$BRANCH_NAME is OPEN. Create a PR once the PR is closed or merged." |
| 51 | + exit 0 |
| 52 | +fi |
0 commit comments