-
Notifications
You must be signed in to change notification settings - Fork 3
105 lines (85 loc) · 2.5 KB
/
Copy pathci.yml
File metadata and controls
105 lines (85 loc) · 2.5 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
name: CI Pipeline
on:
push:
branches: [main]
paths-ignore:
- 'k8s/**'
- 'docs/**'
- '**/*.md'
- terraform/**
workflow_dispatch:
permissions:
id-token: write
contents: read
env:
REGISTRY: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com
jobs:
security:
name: Security Gate
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Gitleaks
uses: gitleaks/gitleaks-action@v2
- name: Hadolint Backend
uses: hadolint/hadolint-action@v3.1.0
with:
dockerfile: backend/Dockerfile
- name: Hadolint Frontend
uses: hadolint/hadolint-action@v3.1.0
with:
dockerfile: frontend/Dockerfile
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: backend/go.mod
cache: true
- name: Run govulncheck
run: |
cd backend
go install golang.org/x/vuln/cmd/govulncheck@latest
govulncheck ./...
build-scan-push:
name: Build, Scan & Push
runs-on: ubuntu-latest
needs: security
strategy:
fail-fast: false
matrix:
service: [backend, frontend]
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- name: Set TAG
run: echo "TAG=${GITHUB_SHA:0:7}" >> $GITHUB_ENV
- name: Configure AWS (OIDC)
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Login to ECR
uses: aws-actions/amazon-ecr-login@v2
- name: Build image
uses: docker/build-push-action@v6
with:
context: ./${{ matrix.service }}
load: true
push: false
tags: |
${{ env.REGISTRY }}/skillpulse-${{ matrix.service }}:${{ env.TAG }}
${{ env.REGISTRY }}/skillpulse-${{ matrix.service }}:latest
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Trivy Scan
uses: aquasecurity/trivy-action@master
with:
image-ref: ${{ env.REGISTRY }}/skillpulse-${{ matrix.service }}:${{ env.TAG }}
format: table
severity: CRITICAL,HIGH
exit-code: 1
ignore-unfixed: true
- name: Push Images
run: |
IMAGE=$REGISTRY/skillpulse-${{ matrix.service }}
docker push $IMAGE:$TAG
docker push $IMAGE:latest