Skip to content

Commit c0a19b4

Browse files
authored
Merge pull request #193 from visier/bug/VAN-143698-action-pull-requests
[VAN-143698] Updating github action to create and merge pull requests.
2 parents 6e8eb48 + 83d9438 commit c0a19b4

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

‎.github/workflows/publish-sdk.yml‎

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ on:
2121
required: false
2222
default: false
2323
type: boolean
24+
should_create_and_merge_pr:
25+
description: 'Whether to create and merge pull request'
26+
required: false
27+
default: false
28+
type: boolean
2429

2530
# Permissions to create PR, to write changes, to use PyPi auth
2631
permissions:
@@ -57,13 +62,13 @@ jobs:
5762
5863
- name: Publish PyPi package
5964
if: github.event_name == 'workflow_dispatch' && github.event.inputs.should_publish_to_pypi == 'true' || github.event_name == 'push'
60-
uses: pypa/gh-action-pypi-publish@v1.12.4
65+
uses: pypa/gh-action-pypi-publish@v1.13.0
6166
with:
6267
packages-dir: "src/${{ matrix.package_folder }}/dist"
6368

6469
create_and_merge_pr:
6570
needs: publish_package
66-
if: needs.publish_package.result == 'success' && (github.event_name == 'workflow_dispatch' && github.event.inputs.from_branch != github.event.inputs.to_branch)
71+
if: needs.publish_package.result == 'success' && (github.event_name == 'workflow_dispatch' && github.event.inputs.should_create_and_merge_pr == 'true' || github.event_name == 'push')
6772
name: Merge PR
6873
runs-on: ubuntu-latest
6974
env:
@@ -73,10 +78,19 @@ jobs:
7378
- name: Check out before merge
7479
uses: actions/checkout@v4
7580

81+
- name: Create a token
82+
id: create-token
83+
uses: actions/create-github-app-token@v2
84+
with:
85+
app-id: ${{ secrets.APP_ID }}
86+
private-key: ${{ secrets.APP_PRIVATE_KEY }}
87+
owner: ${{ github.repository_owner }}
88+
repositories: python-sdk
89+
7690
- name: Create Pull Request
7791
id: create_pr
7892
env:
79-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
93+
GITHUB_TOKEN: ${{ steps.create-token.outputs.token }}
8094
run: |
8195
pr_output=$(gh pr create \
8296
--title "Auto-generated SDK from ${{ env.SOURCE_BRANCH }}" \
@@ -89,6 +103,6 @@ jobs:
89103
90104
- name: Merge Pull Request
91105
env:
92-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
106+
GITHUB_TOKEN: ${{ steps.create-token.outputs.token }}
93107
run: |
94108
gh pr merge ${{ steps.create_pr.outputs.pr_number }} --merge --delete-branch

0 commit comments

Comments
 (0)