Skip to content

Commit

Permalink
Fix delete backport branch workflow (#704)
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Farr <[email protected]>
  • Loading branch information
Xtansia authored Jul 10, 2024
1 parent e76175c commit b8cc8ec
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/backport.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
steps:
- name: GitHub App token
id: github_app_token
if: github.repository == 'opensearch-project/opensearch-net'
uses: tibdex/[email protected]
with:
app_id: ${{ secrets.APP_ID }}
Expand All @@ -24,5 +25,5 @@ jobs:
- name: Backport
uses: VachaShah/[email protected]
with:
github_token: ${{ steps.github_app_token.outputs.token }}
github_token: ${{ steps.github_app_token.outputs.token || secrets.GITHUB_TOKEN }}
branch_name: backport/backport-${{ github.event.number }}
15 changes: 11 additions & 4 deletions .github/workflows/delete_backport_branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,16 @@ on:
jobs:
delete-branch:
runs-on: ubuntu-latest
if: startsWith(github.event.pull_request.head.ref,'backport/')
if: github.event.pull_request.base.repo.id == github.event.pull_request.head.repo.id && startsWith(github.event.pull_request.head.ref, 'backport/')
permissions:
contents: write
steps:
- name: Delete merged branch
uses: SvanBoxel/delete-merged-branch@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: actions/github-script@v7
with:
script: |
github.rest.git.deleteRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `heads/${context.payload.pull_request.head.ref}`,
})

0 comments on commit b8cc8ec

Please sign in to comment.