-
-
Notifications
You must be signed in to change notification settings - Fork 0
114 lines (97 loc) · 2.82 KB
/
deploy.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
name: Deploy
on:
schedule:
- cron: '0 0 * * 1'
push:
branches:
- 'master'
paths:
- 'scss/**'
- 'views/**'
- '*'
- '.github/workflows/deploy.yml'
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
IMAGE_SOURCE: "ghcr.io/${{ github.repository }}:${{ github.ref_name }}"
concurrency:
group: ${{ github.ref }}
cancel-in-progress: false
jobs:
build:
runs-on: ubuntu-latest
environment: default
permissions:
contents: write
packages: write
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
- name: Install dependencies
run: npm install
- name: Build Styles
run: npm run build
- uses: actions/setup-go@v5
with:
go-version: '^1.21.1'
- name: Build Backend
run: GOOS=linux go build
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: anothrNick/[email protected]
id: bump
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WITH_V: false
DEFAULT_BUMP: patch
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{major}}.{{minor}},value=${{ steps.bump.outputs.new_tag }}
type=semver,pattern={{major}},value=${{ steps.bump.outputs.new_tag }}
type=ref,event=branch
type=ref,event=pr
type=raw,value=latest
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
format: 'github'
output: 'dependency-results.sbom.json'
image-ref: ${{ env.IMAGE_SOURCE }}
ignore-unfixed: true
vuln-type: 'os,library'
severity: 'CRITICAL,HIGH'
github-pat: ${{ secrets.GITHUB_TOKEN }}
cleanup:
runs-on: ubuntu-latest
needs: build
permissions:
packages: write
steps:
- uses: actions/delete-package-versions@v5
with:
package-name: video-gallery
package-type: container
min-versions-to-keep: 0
delete-only-untagged-versions: true