From 54b8b71fff8cf5ed508924920b9efda94c939fbb Mon Sep 17 00:00:00 2001 From: Matthew <2565361+mshafer1@users.noreply.github.com> Date: Sat, 26 Aug 2023 12:52:20 -0500 Subject: [PATCH 1/3] use native gh tooling to create PR so checks run. --- .github/workflows/Update-Poetry-Lock.yml | 40 +++++++++++++++++------- 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/.github/workflows/Update-Poetry-Lock.yml b/.github/workflows/Update-Poetry-Lock.yml index 2dcc0a5e..fa59b0a9 100644 --- a/.github/workflows/Update-Poetry-Lock.yml +++ b/.github/workflows/Update-Poetry-Lock.yml @@ -28,27 +28,43 @@ jobs: ref: main # This is the branch the PR is to be created from persist-credentials: true # make the token that is used the GITHUB_TOKEN, instead of your personal token fetch-depth: 0 # otherwise, you will failed to push refs to dest repo - + - name: Store vars + id: vars + run: | + echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT + echo "branch_name=automated-updates/update-poetry-lock" >> $GITHUB_OUTPUT + - name: Create branch + run: git checkout -b ${{ steps.vars.outputs.branch_name }} - uses: actions/setup-python@v2 with: python-version: ${{ env.PYTHON_VERSION }} - uses: Gr1N/setup-poetry@v8 with: poetry-version: ${{ env.POETRY_VERSION }} + - name: Configure git user + # https://github.com/actions/checkout/discussions/479 + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" - name: Check for lock changes run: | poetry lock + git commit -am "Update poetry lock file" || exit 0 poetry install poetry run ni-python-styleguide fix + git commit -am "Update formatting" || true + git push --force --set-upstream origin ${{ steps.vars.outputs.branch_name }} + # based on https://stackoverflow.com/a/73340290/8100990 - name: Create Pull Request - uses: peter-evans/create-pull-request@v4 - with: - commit-message: Update poetry lock and reformat - title: Update Poetry Lock - branch: aotumated-updates/update-poetry-lock - branch-suffix: short-commit-hash - body: | - # Update Poetry Lock - Ran poetry lock, install, then ni-python-styleguide fix to reformat any changes. - base: main - delete-branch: true + run: | + gh pr create -B main -H ${{ steps.vars.outputs.branch_name }} --title 'Update poetry lock and reformat' --body '# Update Poetry Lock + + Ran: + * `poetry lock`, + * `poetry install`, then + * `ni-python-styleguide fix` to reformat any changes. + + \-\-\- + Created by Github action' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 47919ee14da8915c6adcf746b136ba0b567580ba Mon Sep 17 00:00:00 2001 From: Matthew <2565361+mshafer1@users.noreply.github.com> Date: Sat, 26 Aug 2023 12:52:51 -0500 Subject: [PATCH 2/3] PR checks use default types --- .github/workflows/PR.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/PR.yml b/.github/workflows/PR.yml index 16bcc635..20e8394e 100644 --- a/.github/workflows/PR.yml +++ b/.github/workflows/PR.yml @@ -10,9 +10,6 @@ on: - pyproject.toml - docs/Coding-Conventions.md - .github/workflows/PR.yml - types: - - opened - - synchronize env: POETRY_VERSION: 1.2.2 From c152c902d8b1c069b1716d3979d2f9e894901c1e Mon Sep 17 00:00:00 2001 From: Matthew <2565361+mshafer1@users.noreply.github.com> Date: Sat, 26 Aug 2023 13:30:30 -0500 Subject: [PATCH 3/3] Use github.token instead This makes the PR come from github-actions -> https://github.com/mshafer1/ni-python-styleguide/pull/6 --- .github/workflows/Update-Poetry-Lock.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Update-Poetry-Lock.yml b/.github/workflows/Update-Poetry-Lock.yml index fa59b0a9..175c3548 100644 --- a/.github/workflows/Update-Poetry-Lock.yml +++ b/.github/workflows/Update-Poetry-Lock.yml @@ -67,4 +67,4 @@ jobs: \-\-\- Created by Github action' env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_TOKEN: ${{ github.token }}