Skip to content

Commit

Permalink
fix: Handle case where PR is not required
Browse files Browse the repository at this point in the history
  • Loading branch information
nickevansuk committed Mar 22, 2024
1 parent c7ece8a commit e9ecd46
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: Create PR for latest Activity List and Collections
name: Create and merge PR for latest Activity List and Collections

on:
workflow_dispatch:
repository_dispatch:
types: [activity-list-update]

jobs:
generate:
create-and-merge-pr:
runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -65,7 +65,7 @@ jobs:
echo "::set-output name=changed_files::$(cat ../changed_collections_files.txt)"
working-directory: ./activity-list/

- name: Create Pull Request
- name: Create Pull Request (if changes are detected)
if: ${{ steps.compare.outputs.changeDescription || steps.collections_changed.outputs.changed_files }}
id: cpr
uses: peter-evans/create-pull-request@v6
Expand All @@ -90,25 +90,29 @@ jobs:
draft: false

- name: Auto-approve PR
if: ${{ steps.cpr.outputs.pull-request-number }}
uses: hmarr/auto-approve-action@v3
with:
pull-request-number: ${{ steps.cpr.outputs.pull-request-number }}

- name: Check out the PR
if: ${{ steps.cpr.outputs.pull-request-number }}
uses: actions/checkout@v2
with:
ref: ci/update-activity-list
path: pr
fetch-depth: 0

- name: Auto-merge the PR
if: ${{ steps.cpr.outputs.pull-request-number }}
run: gh pr merge "$PR_URL" --auto --body "" --squash
working-directory: ./pr/
env:
PR_URL: ${{ steps.cpr.outputs.pull-request-url }}
GITHUB_TOKEN: ${{secrets.PUBLIC_REPO_ACCESS_TOKEN}}

- name: Check outputs
if: ${{ steps.cpr.outputs.pull-request-number }}
run: |
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"

0 comments on commit e9ecd46

Please sign in to comment.