|
1 | | -name: Hadolint |
| 1 | +name: Lint |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | pull_request: |
|
8 | 8 | - '**/Dockerfile' |
9 | 9 | - '.github/workflows/lint.yml' |
10 | 10 |
|
| 11 | +concurrency: |
| 12 | + group: ${{ github.head_ref }}-${{ github.workflow }} |
| 13 | + cancel-in-progress: true |
| 14 | + |
11 | 15 | jobs: |
12 | 16 | hadolint: |
13 | 17 | runs-on: ubuntu-24.04 |
|
16 | 20 | - uses: hadolint/[email protected] |
17 | 21 | with: |
18 | 22 | recursive: true |
| 23 | + ensure-dockerfiles-up-to-date: |
| 24 | + runs-on: ubuntu-24.04 |
| 25 | + steps: |
| 26 | + - uses: actions/checkout@v4 |
| 27 | + - name: Install GHC and Stack |
| 28 | + uses: haskell-actions/[email protected] |
| 29 | + with: |
| 30 | + enable-stack: true |
| 31 | + |
| 32 | + - name: "Cache .stack-work and ~/.stack" |
| 33 | + |
| 34 | + with: |
| 35 | + path: | |
| 36 | + ~/.stack |
| 37 | + **/.stack-work |
| 38 | + key: ${{ runner.os }}-stack-${{ hashFiles('**/stack.yaml') }} |
| 39 | + restore-keys: | |
| 40 | + ${{ runner.os }}-stack- |
| 41 | +
|
| 42 | + # Enable tmate debugging of manually triggered workflows if the input option was provided |
| 43 | + - name: Setup tmate session |
| 44 | + |
| 45 | + |
| 46 | + - name: Build dockerfiles generator |
| 47 | + run: | |
| 48 | + pushd generator |
| 49 | + stack setup |
| 50 | + stack build --no-terminal |
| 51 | + - name: Ensure Dockerfiles are up-to-date |
| 52 | + run: | |
| 53 | + # Collect the list of Dockerfiles to be built |
| 54 | + mapfile -t dockerfiles < <(find . -type f -name 'Dockerfile' | sort) |
| 55 | + # Generate Dockerfiles using the generate.sh wrapper tool |
| 56 | + for df in "${dockerfiles[@]}"; do |
| 57 | + # Get appropriate YAML data file from the Dockerfile path |
| 58 | + df_dir=$(dirname "${df}") |
| 59 | + df_yaml="${df_dir}.yaml" |
| 60 | + if [ ! -f "${df_yaml}" ]; then |
| 61 | + echo "Error: Missing YAML data file ${df_yaml} for Dockerfile ${df}" |
| 62 | + exit 1 |
| 63 | + fi |
| 64 | + echo "Generating ${df}" |
| 65 | + ./generate.sh "${df_yaml}" "${df}.generated" |
| 66 | + # Compare generated Dockerfile with the existing one |
| 67 | + if ! diff -u "${df}" "${df}.generated"; then |
| 68 | + echo "Error: Dockerfile ${df} is out of date. Please regenerate it." |
| 69 | + exit 1 |
| 70 | + fi |
| 71 | + done |
0 commit comments