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