-
Notifications
You must be signed in to change notification settings - Fork 0
182 lines (155 loc) · 5.55 KB
/
docker.yml
File metadata and controls
182 lines (155 loc) · 5.55 KB
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
name: Docker
on:
push:
branches: [main]
tags: ["v*"]
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
paths:
- "Dockerfile*"
- ".dockerignore"
- "Makefile"
- "src/**"
- "Cargo.*"
- ".github/workflows/docker.yml"
concurrency:
group: docker-${{ github.ref }}
cancel-in-progress: true
env:
IMAGE_NAME: loadnetwork/load-reth
jobs:
# PR smoke build (non-draft PRs). Build only; do not push.
smoke:
name: PR Smoke Build
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.draft == false }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Buildx
uses: docker/setup-buildx-action@v3
- name: Build (no push)
run: make docker-build-local
pr-release:
name: PR Release Path
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.draft == false }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Free disk space
run: |
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc || true
sudo apt-get clean || true
docker system prune -af || true
- name: Set up QEMU (multi-arch)
uses: docker/setup-qemu-action@v3
- name: Set up Buildx
uses: docker/setup-buildx-action@v3
- name: Install cross
uses: taiki-e/install-action@v2
with:
tool: cross
- name: Cache cargo/target
uses: Swatinem/rust-cache@v2
with:
cache-targets: false
- name: Exercise multi-arch release build (no push)
run: make DOCKER_BUILDX_PUSH=false docker-build-push-latest
- name: Upload multi-arch tarball
uses: actions/upload-artifact@v4
with:
name: docker-multiarch-tar
path: dist/load-reth-multiarch.tar
# Pushes to main and tags — build & push multi-arch images
push:
name: Build & Push
runs-on: ubuntu-latest
if: ${{ github.event_name != 'pull_request' }}
permissions:
contents: read
security-events: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Free disk space
run: |
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc || true
sudo apt-get clean || true
docker system prune -af || true
- name: Set up QEMU (multi-arch)
uses: docker/setup-qemu-action@v3
- name: Set up Buildx
uses: docker/setup-buildx-action@v3
# Only filter on main. Tags should always build.
- name: Detect docker-relevant changes
id: changes
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
uses: dorny/paths-filter@v3
with:
filters: |
docker:
- "Dockerfile*"
- ".dockerignore"
- "Makefile"
- "src/**"
- "Cargo.*"
- ".github/workflows/docker.yml"
- name: Log in to Docker Hub
if: ${{ startsWith(github.ref, 'refs/tags/') || steps.changes.outputs.docker == 'true' }}
uses: docker/login-action@v3
with:
registry: docker.io
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Install cross
if: ${{ startsWith(github.ref, 'refs/tags/') || steps.changes.outputs.docker == 'true' }}
uses: taiki-e/install-action@v2
with:
tool: cross
- name: Cache cargo/target
if: ${{ startsWith(github.ref, 'refs/tags/') || steps.changes.outputs.docker == 'true' }}
uses: Swatinem/rust-cache@v2
with:
cache-targets: false
- name: Compute tags
id: meta
if: ${{ startsWith(github.ref, 'refs/tags/') || steps.changes.outputs.docker == 'true' }}
shell: bash
run: |
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
tag="${GITHUB_REF#refs/tags/}"
echo "git_tag=${tag}" >> "$GITHUB_OUTPUT"
echo "print_tag=${tag},latest" >> "$GITHUB_OUTPUT"
else
short_sha="$(echo "${GITHUB_SHA}" | cut -c1-12)"
echo "git_tag=sha-${short_sha}" >> "$GITHUB_OUTPUT"
echo "print_tag=sha-${short_sha},latest" >> "$GITHUB_OUTPUT"
fi
- name: Build & push (multi-arch)
if: ${{ startsWith(github.ref, 'refs/tags/') || steps.changes.outputs.docker == 'true' }}
run: make docker-build-push-latest
env:
DOCKER_IMAGE_NAME: ${{ env.IMAGE_NAME }}
GIT_TAG: ${{ github.ref_name }}
- name: Skip (no docker changes on main)
if: ${{ !startsWith(github.ref, 'refs/tags/') && steps.changes.outputs.docker != 'true' }}
run: echo "No docker-relevant changes on main; skipping build."
- name: Trivy scan
if: ${{ (startsWith(github.ref, 'refs/tags/') || steps.changes.outputs.docker == 'true') && github.event.repository.private == false }}
uses: aquasecurity/trivy-action@master
with:
image-ref: ${{ env.IMAGE_NAME }}:latest
format: sarif
output: trivy-results.sarif
- name: Upload scan
if: ${{ (startsWith(github.ref, 'refs/tags/') || steps.changes.outputs.docker == 'true') && github.event.repository.private == false }}
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: trivy-results.sarif