-
Notifications
You must be signed in to change notification settings - Fork 2
110 lines (99 loc) · 3.51 KB
/
on_pr.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
---
name: Pull Request
on:
# Enable manual running of action if necessary
workflow_dispatch:
# Test build/deploy on PRs to main/master
pull_request:
# Only publish on push to main branch
branches:
- main
# Don't trigger if it's just a documentation update
paths-ignore:
- "**.md"
- "**.MD"
- "**.yml"
- "LICENSE"
- ".gitattributes"
- ".gitignore"
- ".dockerignore"
jobs:
shellcheck:
name: Run shellcheck against shell scripts
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' }}
steps:
- uses: actions/[email protected]
- name: Pull koalaman/shellcheck:stable Image
run: docker pull koalaman/shellcheck:stable
- name: Run Shellcheck against shell scripts
run: docker run --rm -i -v "$PWD:/mnt" koalaman/shellcheck:stable $(find . -type f -exec grep -m1 -l -E '^#!.*sh.*' {} \; | grep -v '/.git/')
hadolint:
name: Run hadolint against docker files
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' }}
steps:
- uses: actions/[email protected]
- name: Pull hadolint/hadolint:latest Image
run: docker pull hadolint/hadolint:latest
- name: Run hadolint against Dockerfiles
run: docker run --rm -i -v "$PWD":/workdir --workdir /workdir --entrypoint hadolint hadolint/hadolint --ignore DL3003 --ignore DL3006 --ignore DL3010 --ignore DL4001 --ignore DL3007 --ignore DL3008 --ignore SC2068 --ignore DL3007 --ignore SC1091 --ignore DL3013 --ignore DL3010 $(find . -type f -iname "Dockerfile*")
test_build:
name: Test Build
runs-on: ubuntu-latest
needs: [shellcheck, hadolint]
strategy:
matrix:
docker-platform:
- linux/amd64
- linux/arm64
- linux/arm/v7
steps:
# Check out our code
- name: Checkout
uses: actions/[email protected]
with:
fetch-depth: 0
# List of files to check to trigger a rebuild on this job
- name: Get specific changed files
id: changed-files-specific
uses: tj-actions/[email protected]
with:
files: |
Dockerfile
rootfs
!*.md
!*.MD
# Set up QEMU for multi-arch builds
- name: Set up QEMU
if: steps.changed-files-specific.outputs.any_changed == 'true'
uses: docker/[email protected]
# Set up buildx for multi platform builds
- name: Set up Docker Buildx
if: steps.changed-files-specific.outputs.any_changed == 'true'
id: buildx
uses: docker/[email protected]
# Build
- name: Test Build
if: steps.changed-files-specific.outputs.any_changed == 'true'
uses: docker/[email protected]
with:
context: .
file: ./Dockerfile
no-cache: true
platforms: ${{ matrix.docker-platform }}
push: false
# Patch dockerfile to remove healthcheck
- name: Patch Dockerfile to remove healthcheck
if: steps.changed-files-specific.outputs.any_changed == 'true'
run: sed '/^HEALTHCHECK /d' < Dockerfile > Dockerfile.nohealthcheck
# Build nohealthcheck
- name: Test Build nohealthcheck
if: steps.changed-files-specific.outputs.any_changed == 'true'
uses: docker/[email protected]
with:
context: .
file: ./Dockerfile.nohealthcheck
no-cache: true
platforms: ${{ matrix.docker-platform }}
push: false