-
Notifications
You must be signed in to change notification settings - Fork 13
100 lines (88 loc) · 3.16 KB
/
build-nightly.yml
File metadata and controls
100 lines (88 loc) · 3.16 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
name: Build OASM Nightly
on:
push:
branches:
- "main"
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
IMAGE_NAME: oasm/oasm
jobs:
detect-changes:
name: Detect Changed Services
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v5
- name: Detect changed services
id: filter
uses: dorny/paths-filter@v3
with:
filters: |
api:
- 'core-api/**'
worker:
- 'worker/**'
console:
- 'console/**'
- id: set-matrix
run: |
CHANGED=()
if [ "${{ steps.filter.outputs.api }}" == "true" ]; then CHANGED+=('"api"'); fi
if [ "${{ steps.filter.outputs.worker }}" == "true" ]; then CHANGED+=('"worker"'); fi
if [ "${{ steps.filter.outputs.console }}" == "true" ]; then CHANGED+=('"console"'); fi
if [ ${#CHANGED[@]} -eq 0 ]; then
MATRIX="{}"
else
MATRIX="{\"service\": [$(IFS=,; echo "${CHANGED[*]}")]}"
fi
echo "matrix=$MATRIX" >> $GITHUB_OUTPUT
build:
name: Build Changed Services
needs: detect-changes
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write
if: ${{ needs.detect-changes.outputs.matrix != '{}' && needs.detect-changes.outputs.matrix != '' }}
strategy:
matrix: ${{ fromJson(needs.detect-changes.outputs.matrix) }}
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Login to image repository
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Set up Docker Buildx with cache support
run: |
docker buildx create --name mybuilder --driver docker-container --use
docker buildx inspect --bootstrap
- name: Build and push
run: |
docker buildx build \
--platform linux/amd64 \
--push \
--cache-from=type=registry,ref=${{ env.IMAGE_NAME }}-${{ matrix.service }}:buildcache \
--cache-to=type=registry,ref=${{ env.IMAGE_NAME }}-${{ matrix.service }}:buildcache,mode=max \
--tag ${{ env.IMAGE_NAME }}-${{ matrix.service }}:dev \
--file ./${{ matrix.service == 'api' && 'core-api' || matrix.service }}/Dockerfile \
./${{ matrix.service == 'api' && 'core-api' || matrix.service }}
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
image-ref: '${{ env.IMAGE_NAME }}-${{ matrix.service }}:dev'
format: 'sarif'
output: 'trivy-results.${{ matrix.service }}.sarif'
ignore-unfixed: true
severity: 'CRITICAL,HIGH'
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v4
with:
sarif_file: 'trivy-results.${{ matrix.service }}.sarif'