Skip to content

Commit da4aee4

Browse files
authored
πŸ‘· Add lint and buid-check workflow (#5)
* πŸ‘· Add lint and buid-check workflow * 🚨 Fix lint errors * πŸ”§ Add .hadolint to ignore rules
1 parent ba447fe commit da4aee4

File tree

5 files changed

+78
-3
lines changed

5 files changed

+78
-3
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Build Check
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.ref }}
9+
cancel-in-progress: true
10+
11+
jobs:
12+
build-check:
13+
name: Build Check
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
22+
- name: Set up Docker Buildx
23+
uses: docker/setup-buildx-action@v3
24+
25+
- name: Build image (validation only)
26+
uses: docker/build-push-action@v6.15.0
27+
with:
28+
context: .
29+
push: false
30+
tags: ghcr.io/${{ github.repository }}:pr-check
31+
cache-from: type=gha,scope=image
32+
cache-to: type=gha,mode=max,scope=image
33+
34+
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Code Lint
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.ref }}
9+
cancel-in-progress: true
10+
11+
jobs:
12+
lint-dockerfile:
13+
name: Lint Dockerfile
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
22+
- name: Lint Dockerfile with hadolint
23+
uses: hadolint/hadolint-action@v3.1.0
24+
with:
25+
dockerfile: ./Dockerfile
26+
config: .hadolint.yaml
27+
28+

β€Ž.github/workflows/docker-publish.ymlβ€Ž

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ on:
44
push:
55
branches: [main]
66

7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.ref }}
9+
cancel-in-progress: true
10+
711
jobs:
812
build-and-push:
913
runs-on: ubuntu-latest

β€Ž.hadolint.yamlβ€Ž

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# .hadolint.yaml
2+
ignored:
3+
- DL3007 # Using latest is prone to errors if the image will ever update
4+
- DL3008 # Pin versions in apt get install
5+
- DL3013 # Pin versions in pip install
6+
- DL3016 # Pin versions in npm install

β€ŽDockerfileβ€Ž

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@ FROM ghcr.io/actions/actions-runner:latest
22

33
USER root
44

5+
# Set shell with pipefail for better error handling
6+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
7+
58
# Update and install base dependencies
69
RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
7-
&& apt update \
8-
&& apt install -y --no-install-recommends \
10+
&& apt-get update \
11+
&& apt-get install -y --no-install-recommends \
912
# System build tools
1013
autoconf \
1114
automake \
@@ -37,7 +40,7 @@ RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
3740
zip \
3841
# Linters/Formatters
3942
yamllint \
40-
&& apt clean \
43+
&& apt-get clean \
4144
&& rm -rf /var/lib/apt/lists/*
4245

4346
# Install AWS CLI

0 commit comments

Comments
Β (0)