-
Notifications
You must be signed in to change notification settings - Fork 108
71 lines (65 loc) · 1.98 KB
/
Copy pathdocker-build.yml
File metadata and controls
71 lines (65 loc) · 1.98 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
name: Docker Build
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: read
packages: write
concurrency:
group: docker-build-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
changes:
runs-on: ubuntu-latest
outputs:
code: ${{ steps.filter.outputs.code }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: dorny/paths-filter@v4
id: filter
with:
filters: |
code:
- 'src/**'
- 'proto/**'
- 'Cargo.toml'
- 'Cargo.lock'
- 'rust-toolchain*'
- 'Dockerfile'
- '.dockerignore'
- '.github/workflows/docker-build.yml'
- '.github/workflows/docker-build-impl.yml'
build:
needs: changes
if: needs.changes.outputs.code == 'true'
uses: ./.github/workflows/docker-build-impl.yml
secrets: inherit
docker-build-required:
needs: [changes, build]
if: always()
runs-on: ubuntu-latest
steps:
- name: Evaluate docker build result
env:
CHANGES_RESULT: ${{ needs.changes.result }}
CODE_CHANGED: ${{ needs.changes.outputs.code }}
BUILD_RESULT: ${{ needs.build.result }}
run: |
if [[ "$CHANGES_RESULT" != "success" ]]; then
echo "docker-build-required failing: changes job did not succeed (result: $CHANGES_RESULT)"
exit 1
fi
if [[ "$BUILD_RESULT" == "success" ]]; then
echo "docker-build-required passing: build succeeded"
exit 0
fi
if [[ "$BUILD_RESULT" == "skipped" && "$CODE_CHANGED" != "true" ]]; then
echo "docker-build-required passing: build intentionally skipped (no code changes)"
exit 0
fi
echo "docker-build-required failing (build job: $BUILD_RESULT, code changed: $CODE_CHANGED)"
exit 1