Skip to content

Commit

Permalink
PTFE-1063 reusable workflow to disallow the merge of large files (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
tcarmet authored Nov 6, 2023
1 parent efe1a91 commit 251074d
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 1 deletion.
38 changes: 38 additions & 0 deletions .github/workflows/lfs-warning.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---

# This workflow is a reusable workflow meant to be called on pull_request events.
# The goal is to check the files in the pull request to make sure they respect the file size limit.
# If the file size limit is exceeded, and the file has not been commited via git lfs, then
# the workflow will fail, a label will be added to the pull request along with a comment.

name: lfs-warning

on:
workflow_call:
inputs:
filesizelimit:
description: 'The file size limit'
required: false
default: 1MB
type: string
labelname:
description: 'The label name'
required: false
default: bug
type: string

permissions:
pull-requests: write
contents: read

jobs:
lfs-warning:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: lfs warning
uses: ppremk/[email protected]
with:
filesizelimit: ${{ inputs.filesizelimit }}
labelName: ${{ inputs.labelname }}
6 changes: 5 additions & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
on: push
on: pull_request

permissions:
packages: write
contents: read
security-events: write
pull-requests: write

jobs:
docker-build:
Expand All @@ -17,3 +18,6 @@ jobs:
uses: ./.github/workflows/trivy.yaml
with:
name: '/test'

lfs-warning:
uses: ./.github/workflows/lfs-warning.yaml
40 changes: 40 additions & 0 deletions docs/lfs-warning.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Git LFS warning

The `lfs-warning.yaml` workflow will check if the files committed
in a pull request are properly tracked by Git LFS when needed.

## Usage

This workflow can be called as a job in any workflow that needs,
for example:

```yaml
# my-workflow.yaml
on: pull_request

jobs:
lfs-warning:
uses: scality/workflows/.github/workflows/lfs-warning.yaml@v1
```
## Inputs
Additional inputs to modify the default behavior of the workflow.
| Name | Description | Default |
| --------------- | ------------------------------------------ | ------- |
| `filesizelimit` | Maximum file size before warning | `1MB` |
| `labelname` | Label name to use when a warning is issued | `bug` |

```yaml
# my-workflow.yaml
on: pull_request
jobs:
lfs-warning:
uses: scality/workflows/.github/workflows/lfs-warning.yaml@v1
with:
filesizelimit: 10MB
labelname: 'my-label'
```
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ nav:
- Home: index.md
- Docker build: docker-build.md
- Trivy: trivy.md
- Git LFS warning: lfs-warning.md
- Known issues: known-issues.md

markdown_extensions:
Expand Down

0 comments on commit 251074d

Please sign in to comment.