Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:
pull_request:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
bootstrap:
runs-on: ubuntu-latest
Expand Down
28 changes: 27 additions & 1 deletion {{ cookiecutter.name }}/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,39 @@ on:
- main
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
lint:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
outputs:
image-build-affected: ${{ steps.image-build-affected.outputs.result }}

steps:
- name: checkout
uses: actions/checkout@v4

- name: Check whether the pull request can affect the image build
id: image-build-affected
if: github.event_name == 'pull_request'
env:
GH_TOKEN: ${{ github.token }}
PR_NUMBER: ${{ github.event.pull_request.number }}
REPO: ${{ github.repository }}
run: |
set -euo pipefail
changed=$(gh api --paginate "/repos/$REPO/pulls/$PR_NUMBER/files" --jq '.[].filename')
if grep -qxE 'Dockerfile|uv\.lock|pyproject\.toml|\.dockerignore' <<< "$changed"; then
echo "result=true" >> "$GITHUB_OUTPUT"
else
echo "result=false" >> "$GITHUB_OUTPUT"
fi

- name: setup project
id: setup-project
uses: ./.github/actions/setup-project
Expand Down Expand Up @@ -67,7 +92,8 @@ jobs:
run: make test

build-docker-image:
needs: test
needs: [lint, test]
if: github.event_name != 'pull_request' || needs.lint.outputs.image-build-affected == 'true'
runs-on: ubuntu-latest

steps:
Expand Down
Loading