From 229707a3a971786354c4993fb48bd1ba2d40cee6 Mon Sep 17 00:00:00 2001 From: hlts2 Date: Tue, 8 Oct 2024 18:09:21 +0900 Subject: [PATCH] fix: verify Signed-off-by: hlts2 --- .github/workflows/backport-check.yaml | 66 +++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 .github/workflows/backport-check.yaml diff --git a/.github/workflows/backport-check.yaml b/.github/workflows/backport-check.yaml new file mode 100644 index 0000000000..a305dcbc37 --- /dev/null +++ b/.github/workflows/backport-check.yaml @@ -0,0 +1,66 @@ +# +# Copyright (C) 2019-2024 vdaas.org vald team +# +# 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 +# +# 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. +# +# DO NOT MERGE THIS FILE +name: "Run backport PR" +on: + push: + branches: + - main + - "release/v*.*" + - "!release/v*.*.*" +env: + TARGET_LABEL_NAME_PREFIX: "actions/backport/" + BACKPORT_BRANCH_NAME_PREFIX: "backport" + FETCHED_GITHUB_INFO_PATH: /tmp/github_info.json + GITHUB_USER: ${{ secrets.DISPATCH_USER }} + GITHUB_TOKEN: ${{ secrets.DISPATCH_TOKEN }} +jobs: + dump-contexts-to-log: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/dump-context + create: + runs-on: ubuntu-latest + needs: [dump-contexts-to-log] + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ secrets.DISPATCH_TOKEN }} + - name: Set Git config + run: | + git config --global --add safe.directory ${GITHUB_WORKSPACE} + - uses: crazy-max/ghaction-import-gpg@v6 + with: + gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} + git_user_signingkey: true + git_commit_gpgsign: true + - name: Fetch PR info + run: | + gh pr list --limit 20 --json number,title,body,labels,headRefName,headRefOid,mergeCommit --state merged | \ + jq --arg oid "83de9c809ffd10880caf5bcd45064bf9162f5900" '.[] | select(.mergeCommit.oid == $oid)' > ${FETCHED_GITHUB_INFO_PATH} + cat ${FETCHED_GITHUB_INFO_PATH} + echo "========" + gh pr list --limit 20 --json number,title,body,labels,headRefName,headRefOid,mergeCommit --state merged + echo "========" + echo ${GITHUB_SHA} + - name: Set context + id: set_context + run: | + LABEL_NAMES=`cat ${FETCHED_GITHUB_INFO_PATH} | jq -r --arg PREFIX $TARGET_LABEL_NAME_PREFIX '[.labels[]? | select(.name | startswith($PREFIX)) | .name] | join(" ")'` + echo "LABEL_NAMES=${LABEL_NAMES}" >> $GITHUB_OUTPUT # e.g.) actions/backport/v1.7 actions/backport/v1.8 + echo "${LABEL_NAMES}"