Skip to content

Commit 2b0f0b9

Browse files
authored
Use native gh tooling to raise pr (#138)
* use native gh tooling to create PR so checks run. * PR checks use default types * Use github.token instead This makes the PR come from github-actions -> mshafer1#6
1 parent 622d496 commit 2b0f0b9

File tree

2 files changed

+28
-15
lines changed

2 files changed

+28
-15
lines changed

.github/workflows/PR.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ on:
1010
- pyproject.toml
1111
- docs/Coding-Conventions.md
1212
- .github/workflows/PR.yml
13-
types:
14-
- opened
15-
- synchronize
1613

1714
env:
1815
POETRY_VERSION: 1.2.2

.github/workflows/Update-Poetry-Lock.yml

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,27 +28,43 @@ jobs:
2828
ref: main # This is the branch the PR is to be created from
2929
persist-credentials: true # make the token that is used the GITHUB_TOKEN, instead of your personal token
3030
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo
31-
31+
- name: Store vars
32+
id: vars
33+
run: |
34+
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
35+
echo "branch_name=automated-updates/update-poetry-lock" >> $GITHUB_OUTPUT
36+
- name: Create branch
37+
run: git checkout -b ${{ steps.vars.outputs.branch_name }}
3238
- uses: actions/setup-python@v2
3339
with:
3440
python-version: ${{ env.PYTHON_VERSION }}
3541
- uses: Gr1N/setup-poetry@v8
3642
with:
3743
poetry-version: ${{ env.POETRY_VERSION }}
44+
- name: Configure git user
45+
# https://github.com/actions/checkout/discussions/479
46+
run: |
47+
git config user.name "github-actions[bot]"
48+
git config user.email "github-actions[bot]@users.noreply.github.com"
3849
- name: Check for lock changes
3950
run: |
4051
poetry lock
52+
git commit -am "Update poetry lock file" || exit 0
4153
poetry install
4254
poetry run ni-python-styleguide fix
55+
git commit -am "Update formatting" || true
56+
git push --force --set-upstream origin ${{ steps.vars.outputs.branch_name }}
57+
# based on https://stackoverflow.com/a/73340290/8100990
4358
- name: Create Pull Request
44-
uses: peter-evans/create-pull-request@v4
45-
with:
46-
commit-message: Update poetry lock and reformat
47-
title: Update Poetry Lock
48-
branch: aotumated-updates/update-poetry-lock
49-
branch-suffix: short-commit-hash
50-
body: |
51-
# Update Poetry Lock
52-
Ran poetry lock, install, then ni-python-styleguide fix to reformat any changes.
53-
base: main
54-
delete-branch: true
59+
run: |
60+
gh pr create -B main -H ${{ steps.vars.outputs.branch_name }} --title 'Update poetry lock and reformat' --body '# Update Poetry Lock
61+
62+
Ran:
63+
* `poetry lock`,
64+
* `poetry install`, then
65+
* `ni-python-styleguide fix` to reformat any changes.
66+
67+
\-\-\-
68+
Created by Github action'
69+
env:
70+
GH_TOKEN: ${{ github.token }}

0 commit comments

Comments
 (0)