-
Notifications
You must be signed in to change notification settings - Fork 1
96 lines (80 loc) · 3.17 KB
/
secure-pipeline.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
name: java-goof image build and deployment
on:
push:
branches:
- 'master'
pull_request:
branches:
- 'master'
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
jobs:
build-todolist-image:
runs-on: ubuntu-latest
defaults:
run:
working-directory: todolist-goof
steps:
- uses: actions/checkout@v4.1.1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Build
uses: docker/build-push-action@v2
with:
load: true
context: todolist-goof
push: false
tags: java-goof:latest
- id: auth
uses: google-github-actions/auth@v2
with:
credentials_json: "${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}"
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2
- name: Install gke-gcloud-auth-plugin
run: gcloud components install kubectl
- name: Check gke-gcloud-auth-plugin
run: kubectl version --client
- name: Use gcloud CLI
run: gcloud info
- name: Docker auth
run: gcloud auth configure-docker us-central-1-docker.pkg.dev --quiet
- name: Set version
id: version
run: echo "VERSION=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: build and push the docker image
env:
GOOGLE_PROJECT: ${{ secrets.GOOGLE_PROJECT }}
VERSION: ${{ steps.version.outputs.VERSION }}
run: |
DOCKER_IMAGE="us-central1-docker.pkg.dev/${GOOGLE_PROJECT}/java-goof/goof:${VERSION}"
gcloud auth configure-docker us-central1-docker.pkg.dev
docker build -t $DOCKER_IMAGE .
docker push ${DOCKER_IMAGE}
- name: Trend Micro Container Vulnerability Scan
env:
GOOGLE_PROJECT: ${{ secrets.GOOGLE_PROJECT }}
VERSION: ${{ steps.version.outputs.VERSION }}
run: |
DOCKER_IMAGE="us-central1-docker.pkg.dev/${GOOGLE_PROJECT}/java-goof/goof:${VERSION}"
export TMAS_API_KEY=${{ secrets.TMAS_API_KEY }}
curl -s -L https://gist.github.com/raphabot/abae09b46c29afc7c3b918b7b8ec2a5c/raw/ | bash
tmas scan registry:${DOCKER_IMAGE}
- name: Trend Micro Container Secret Scan
env:
GOOGLE_PROJECT: ${{ secrets.GOOGLE_PROJECT }}
VERSION: ${{ steps.version.outputs.VERSION }}
run: |
DOCKER_IMAGE="us-central1-docker.pkg.dev/${GOOGLE_PROJECT}/java-goof/goof:${VERSION}"
export TMAS_API_KEY=${{ secrets.TMAS_API_KEY }}
curl -s -L https://gist.github.com/raphabot/abae09b46c29afc7c3b918b7b8ec2a5c/raw/ | bash
tmas scan secrets registry:${DOCKER_IMAGE}
- name: Deploy to GKE
env:
GOOGLE_PROJECT: ${{ secrets.GOOGLE_PROJECT }}
VERSION: ${{ steps.version.outputs.VERSION }}
run: |
gcloud container clusters get-credentials igorsdevcluster --region us-central1-a
sed -i "s/GOOGLE_PROJECT/$GOOGLE_PROJECT/g; s/VERSION/$VERSION/g" k8s/java-goof.yaml
kubectl apply -f k8s/java-goof.yaml