-
Notifications
You must be signed in to change notification settings - Fork 0
112 lines (94 loc) · 3.42 KB
/
Copy pathmain.yaml
File metadata and controls
112 lines (94 loc) · 3.42 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
name: Build and Contain ASP.NET Razor Pages Web Application
on:
push:
branches:
- master
- develop
- feature/sql-setup
pull_request:
branches:
- master
jobs:
build-and-push:
runs-on: ubuntu-latest
outputs:
image-tag: ${{ steps.vars.outputs.tag }}
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Generate image tag from commit
id: vars
run: |
COMMIT=$(git rev-parse --short HEAD)
echo "tag=$COMMIT" >> $GITHUB_OUTPUT
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5.7.0
with:
images: ongeziwe17/taskapp:${{ steps.vars.outputs.tag }}
- name: Print Image Tag
run: echo "Docker image tag - ${{ steps.vars.outputs.tag }}"
- name: Docker Login to Hub Registry
uses: docker/login-action@v3.4.0
with:
registry: docker.io
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
logout: false
- name: Docker Setup Buildx
uses: docker/setup-buildx-action@v3.10.0
- name: Verify Docker Login
run: docker info
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: true
no-cache: true
tags: ongeziwe17/taskapp:${{ steps.vars.outputs.tag }}
labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.outputs.annotations }}
- name: Scan image with Trivy
uses: aquasecurity/trivy-action@master
with:
image-ref: ongeziwe17/taskapp:${{ steps.vars.outputs.tag }}
format: table
ignore-unfixed: true
vuln-type: 'os,library'
severity: 'CRITICAL,HIGH,MEDIUM,LOW'
# - name: Docker Scout Image CVE Scan
# id: docker-scout
# if: ${{ github.event_name == 'pull_request' || 'push' }}
# uses: docker/scout-action@v1.18.0
# with:
# command: compare
# image: ${{ steps.vars.outputs.tags }}
# ignore-unchanged: true
# only-severities: critical,high,medium,low
# dockerhub-user: ${{ secrets.DOCKERHUB_USERNAME }}
# dockerhub-password: ${{ secrets.DOCKERHUB_PASSWORD }}
# github-token: ${{ secrets.GIT_TOKEN }}
TaskApp_Deploy_Update_Tag_Value_Helm:
runs-on: ubuntu-latest
needs: build-and-push
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Setup Ubuntu for GitHub
run: |
git --version
git config --global user.name "${{ secrets.GIT_USER_NAME }}"
git config --global user.email "${{ secrets.GIT_USER_EMAIL }}"
git config --global --list
git clone https://${{ secrets.GIT_TOKEN }}@${{ secrets.TASKAPP_DEPLOY_REPOSITORY }}
cd TaskApp-Deploy
ls -a
git checkout feature/sql-setup
ls -a
echo "Updating Docker tag in values.yaml..."
sed -i "s/tag: .*/tag: \"${{ needs.build-and-push.outputs.image-tag }}\"/" values.yaml
echo "Commit and push the change..."
git add values.yaml
git commit -m "Update Docker tag to ${{ needs.build-and-push.outputs.image-tag }}"
cat values.yaml
git push origin feature/sql-setup