Skip to content

Commit

Permalink
Add more
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>
  • Loading branch information
peterzhuamazon committed Apr 2, 2024
1 parent 9418f55 commit a188c14
Showing 1 changed file with 33 additions and 31 deletions.
64 changes: 33 additions & 31 deletions .github/workflows/backport.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Backport
on: [pull_request]
# pull_request_target:
# types:
# - closed
# - labeled
on:
pull_request_target:
types:
- closed
- labeled

jobs:
backport:
Expand All @@ -14,34 +14,36 @@ jobs:
name: Backport
# Only react to merged PRs for security reasons.
# See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target.
# if: >
# github.event.pull_request.merged
# && (
# github.event.action == 'closed'
# || (
# github.event.action == 'labeled'
# && contains(github.event.label.name, 'backport')
# )
# )
if: >
github.event.pull_request.merged
&& (
github.event.action == 'closed'
|| (
github.event.action == 'labeled'
&& contains(github.event.label.name, 'backport')
)
)
steps:
# - name: GitHub App token
# id: github_app_token
# uses: tibdex/github-app-token@v1.5.0
# with:
# app_id: ${{ secrets.APP_ID }}
# private_key: ${{ secrets.APP_PRIVATE_KEY }}
# # opensearch-trigger-bot installation ID
# #installation_id: 22958780
- name: GitHub App token
id: github_app_token
uses: tibdex/github-app-token@v1.5.0
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}
# opensearch-trigger-bot installation ID
#installation_id: 22958780

# - name: Backport
# uses: VachaShah/backport@v2.1.0
# with:
# github_token: ${{ steps.github_app_token.outputs.token }}
# head_template: backport/backport-<%= number %>-to-<%= base %>
- name: Backport
uses: VachaShah/backport@v2.1.0
with:
github_token: ${{ steps.github_app_token.outputs.token }}
head_template: backport/backport-<%= number %>-to-<%= base %>

- name: Check gh
- name: Label new backport PR with backport-automerge label
run: |
PR_BRANCH=test123123
gh pr list -R peterzhuamazon/documentation-website --json "number,headRefName" --state open | jq -r ".[] | select(.headRefName == \"$PR_BRANCH\") | .number"
PR_BRANCH=backport/backport-<%= number %>-to-<%= base %>
PR_NUMBER=`gh pr list -R peterzhuamazon/documentation-website --json "number,headRefName" --state open | jq -r ".[] | select(.headRefName == \"$PR_BRANCH\") | .number"`
echo "Update Backport PR #$PR_NUMBER on branch $PR_BRANCH with backport-automerge label"
gh issue edit -R peterzhuamazon/documentation-website $PR_NUMBER --add-label backport-automerge
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ steps.github_app_token.outputs.token }}

0 comments on commit a188c14

Please sign in to comment.