From 0212109e980ef06137fa6e12b302331c62a81128 Mon Sep 17 00:00:00 2001 From: oviner Date: Tue, 15 Aug 2023 15:45:14 +0300 Subject: [PATCH 1/5] add github actions --- .github/workflows/cherry-pick.yml | 37 +++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/cherry-pick.yml diff --git a/.github/workflows/cherry-pick.yml b/.github/workflows/cherry-pick.yml new file mode 100644 index 0000000..7bce1b1 --- /dev/null +++ b/.github/workflows/cherry-pick.yml @@ -0,0 +1,37 @@ +name: Cherry-Pick PRs to Master + +on: + pull_request: + types: + - closed + +jobs: + cherry-pick: + runs-on: ubuntu-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + + - name: Set Up Git + run: | + git config --global user.name "GitHub Actions" + git config --global user.email "actions@github.com" + + # Fetch all branches and tags to ensure we have the latest references + git fetch --prune --unshallow --tags + + - name: Cherry-Pick PR Changes + run: | + # Get the PR number from the environment variable + PR_NUMBER=${{ github.event.pull_request.number }} + + # Print the PR_NUMBER + echo "PR Labels: $PR_NUMBER" + + # Use GitHub CLI to fetch the labels of the PR + PR_LABELS=$(gh pr view $PR_NUMBER --json labels.*.name --jq '.[].name') + + # Print the labels + echo "PR Labels: $PR_LABELS" + \ No newline at end of file From 5ab2228854ad2752cde776697da69012a0a5ef07 Mon Sep 17 00:00:00 2001 From: oviner Date: Tue, 15 Aug 2023 15:47:24 +0300 Subject: [PATCH 2/5] pr-test1 --- pr-test1.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 pr-test1.md diff --git a/pr-test1.md b/pr-test1.md new file mode 100644 index 0000000..7f6982e --- /dev/null +++ b/pr-test1.md @@ -0,0 +1 @@ +pr-test1 From 25961f1c3c5a22f682d3452970f889935a07befd Mon Sep 17 00:00:00 2001 From: oviner Date: Tue, 15 Aug 2023 16:56:01 +0300 Subject: [PATCH 3/5] fix --- .github/workflows/cherry-pick.yml | 32 ++++++++++--------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/.github/workflows/cherry-pick.yml b/.github/workflows/cherry-pick.yml index 7bce1b1..49fd019 100644 --- a/.github/workflows/cherry-pick.yml +++ b/.github/workflows/cherry-pick.yml @@ -6,32 +6,20 @@ on: - closed jobs: - cherry-pick: + get_labels: runs-on: ubuntu-latest - steps: - name: Checkout Repository uses: actions/checkout@v2 - - name: Set Up Git + - name: Get Merged PR Labels + id: merged_pr run: | - git config --global user.name "GitHub Actions" - git config --global user.email "actions@github.com" - - # Fetch all branches and tags to ensure we have the latest references - git fetch --prune --unshallow --tags - - - name: Cherry-Pick PR Changes + PR_NUMBER=$(jq -r '.pull_request.number' "$GITHUB_EVENT_PATH") + ACCESS_TOKEN="${{ secrets.GITHUB_TOKEN }}" + LABELS=$(curl -s -H "Authorization: Bearer $ACCESS_TOKEN" "https://api.github.com/repos/${{ github.repository }}/pulls/$PR_NUMBER" | jq -r '.labels[].name') + echo "::set-output name=labels::$LABELS" + - name: Print Merged PR Labels run: | - # Get the PR number from the environment variable - PR_NUMBER=${{ github.event.pull_request.number }} - - # Print the PR_NUMBER - echo "PR Labels: $PR_NUMBER" - - # Use GitHub CLI to fetch the labels of the PR - PR_LABELS=$(gh pr view $PR_NUMBER --json labels.*.name --jq '.[].name') - - # Print the labels - echo "PR Labels: $PR_LABELS" - \ No newline at end of file + echo "Merged PR Labels: ${{ steps.merged_pr.outputs.labels }}" + \ No newline at end of file From fcf9bacef921e24b163b484f6c70730682a2c68c Mon Sep 17 00:00:00 2001 From: oviner Date: Tue, 15 Aug 2023 17:08:13 +0300 Subject: [PATCH 4/5] fix --- .github/workflows/cherry-pick.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/cherry-pick.yml b/.github/workflows/cherry-pick.yml index 49fd019..5376b48 100644 --- a/.github/workflows/cherry-pick.yml +++ b/.github/workflows/cherry-pick.yml @@ -18,8 +18,5 @@ jobs: PR_NUMBER=$(jq -r '.pull_request.number' "$GITHUB_EVENT_PATH") ACCESS_TOKEN="${{ secrets.GITHUB_TOKEN }}" LABELS=$(curl -s -H "Authorization: Bearer $ACCESS_TOKEN" "https://api.github.com/repos/${{ github.repository }}/pulls/$PR_NUMBER" | jq -r '.labels[].name') - echo "::set-output name=labels::$LABELS" - - name: Print Merged PR Labels - run: | - echo "Merged PR Labels: ${{ steps.merged_pr.outputs.labels }}" + echo "Merged PR Labels: ${{ LABELS }}" \ No newline at end of file From 4b5478a1d0a0006953a92698d78b2f4982921049 Mon Sep 17 00:00:00 2001 From: oviner Date: Tue, 15 Aug 2023 17:11:51 +0300 Subject: [PATCH 5/5] fxi --- pr4 | 1 + 1 file changed, 1 insertion(+) create mode 100644 pr4 diff --git a/pr4 b/pr4 new file mode 100644 index 0000000..0446738 --- /dev/null +++ b/pr4 @@ -0,0 +1 @@ +pr4 \ No newline at end of file