Repository navigation
95 lines (82 loc) · 2.69 KB
/
Copy pathmain.yml
File metadata and controls
95 lines (82 loc) · 2.69 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
name: widget-server pipe ECR
on:
push:
branches:
- 'main'
jobs:
Build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
- name: Configure node
id: configure-node
uses: actions/setup-node@v4
with:
node-version: 22
- name: Install pnpm
id: install-pnpm
uses: pnpm/action-setup@v4
with:
version: 10.28.1
- name: Install dependencies
id: install-dependencies
run: |
pnpm install
- name: Configure AWS Credentials
id: configure-aws-credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ vars.AWS_REGION }}
- name: Login to AWS ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: Set up Docker Buildx
id: set-up-docker-buildx
uses: docker/setup-buildx-action@v3
- name: Generate tag
id: generate-tag
run: |
SHA=$(echo $GITHUB_SHA | head -c7)
echo "sha=$SHA" >> $GITHUB_OUTPUT
- name: Build and export image
id: build-and-export-image
uses: docker/build-push-action@v6
with:
context: .
load: true
cache-from: type=gha
cache-to: type=gha,mode=max
tags: |
${{ steps.login-ecr.outputs.registry }}/${{ vars.ECR_REPOSITORY }}:test
- name: Run Trivy scanner
id: run-trivy-scanner
uses: aquasecurity/trivy-action@v0.36.0
with:
image-ref: '${{ steps.login-ecr.outputs.registry }}/${{ vars.ECR_REPOSITORY }}:test'
format: 'table'
ignore-unfixed: true
vuln-type: 'os,library'
severity: 'CRITICAL,HIGH,MEDIUM,LOW'
- name: Build and push image to AWS ECR
id: build-push-image
uses: docker/build-push-action@v6
with:
context: .
push: true
cache-from: type=gha
tags: |
${{ steps.login-ecr.outputs.registry }}/${{ vars.ECR_REPOSITORY }}:${{ steps.generate-tag.outputs.sha }}
# - name: Build and push image to AWS ECR
# id: build-push-image
# env:
# ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
# ECR_REPOSITORY: ${{ vars.ECR_REPOSITORY }}
# IMAGE_TAG: ${{ steps.generate-tag.outputs.sha }}
# run: |
# docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
# docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG