Skip to content

Commit

Permalink
conditionally run jobs on push
Browse files Browse the repository at this point in the history
  • Loading branch information
microdev1 committed Mar 10, 2023
1 parent 353411a commit 64ba371
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
18 changes: 12 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ on:
pull_request:
release:
types: [published]
check_suite:
types: [rerequested]

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
Expand Down Expand Up @@ -64,24 +62,32 @@ jobs:
PULL: ${{ github.event.number }}
GITHUB_TOKEN: ${{ github.token }}
EXCLUDE_COMMIT: ${{ github.event.pull_request.head.sha }}
- name: Set head sha
- name: Set head sha (pull)
if: github.event_name == 'pull_request'
run: echo "HEAD_SHA=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV
- name: Set base sha
- name: Set base sha (pull)
if: github.event_name == 'pull_request'
run: |
git fetch --no-tags --no-recurse-submodules --depth=$((DEPTH + 1)) origin $HEAD_SHA
echo "BASE_SHA=$(git rev-list $HEAD_SHA --skip=$DEPTH --max-count=1)" >> $GITHUB_ENV
env:
DEPTH: ${{ steps.get-last-commit-with-checks.outputs.commit_depth || github.event.pull_request.commits }}
- name: Set head sha (push)
if: github.event_name == 'push'
run: echo "HEAD_SHA=${{ github.event.after }}" >> $GITHUB_ENV
- name: Set base sha (push)
if: github.event_name == 'push'
run: git cat-file -e $SHA && echo "BASE_SHA=$SHA" >> $GITHUB_ENV || true
env:
SHA: ${{ github.event.before }}
- name: Get changes
id: get-changes
if: github.event_name == 'pull_request'
if: env.BASE_SHA && env.HEAD_SHA
run: echo $(git diff $BASE_SHA...$HEAD_SHA --name-only) | echo "changed_files=[\"$(sed "s/ /\", \"/g")\"]" >> $GITHUB_OUTPUT
- name: Set matrix
id: set-matrix
working-directory: tools
run: python3 -u ci_set_matrix.py
working-directory: tools
env:
CHANGED_FILES: ${{ steps.get-changes.outputs.changed_files }}
LAST_FAILED_JOBS: ${{ steps.get-last-commit-with-checks.outputs.check_runs }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/create-website-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ name: Update CircuitPython.org

on:
release:
types: [published, rerequested]
types: [published]

jobs:
website:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
name: pre-commit

on:
pull_request:
push:
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
Expand Down

0 comments on commit 64ba371

Please sign in to comment.