-
Notifications
You must be signed in to change notification settings - Fork 2
139 lines (120 loc) · 4.64 KB
/
build.yaml
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
name: Run tests with coverage
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
env:
PROJECT_NAME: Arcane.Operator
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
validate_commit:
name: Validate commit
runs-on: ubuntu-latest
if: ${{ github.ref != 'refs/heads/main' }}
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/[email protected]
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet clean && dotnet nuget locals all --clear && dotnet restore
- name: Test
working-directory: ./test
run: |
dotnet add package coverlet.msbuild
dotnet test ${PROJECT_NAME}.Tests.csproj --configuration Debug --runtime linux-x64 /p:CollectCoverage=true /p:CoverletOutput=Coverage/ /p:CoverletOutputFormat=lcov --logger GitHubActions
- name: Publish Code Coverage
if: ${{ github.event_name == 'pull_request' && always() }}
uses: romeovs/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
lcov-file: ./test/Coverage/coverage.info
- name: Check style
run: dotnet format --verify-no-changes
build_image:
name: Build Docker Image and Helm Charts
runs-on: ubuntu-latest
needs: [ validate_commit ]
if: ${{ always() && (needs.validate_commit.result == 'success' || needs.validate_commit.result == 'skipped') }}
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Log in to the Container registry
uses: docker/[email protected]
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Get project version
uses: SneaksAndData/github-actions/[email protected]
id: version
- 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={{version}},value=${{steps.version.outputs.version}}
flavor:
latest=false
- name: Set up Docker Buildx
uses: docker/[email protected]
with:
use: true
platforms: linux/arm64,linux/amd64
- name: Build and push Docker image
uses: docker/[email protected]
with:
context: .
file: .container/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/arm64,linux/amd64
- name: Build and Push Chart
uses: SneaksAndData/github-actions/[email protected]
with:
application: arcane-operator
app_version: ${{ steps.meta.outputs.version }}
container_registry_user: ${{ github.actor }}
container_registry_token: ${{ secrets.GITHUB_TOKEN }}
container_registry_address: ghcr.io/sneaksanddata/
# AWS ECR Public Registry related steps
- name: Import AWS Secrets
uses: hashicorp/[email protected]
if: ${{ startsWith(github.ref, 'refs/tags') }}
with:
url: https://hashicorp-vault.awsp.sneaksanddata.com/
role: github
method: jwt
secrets: |
/secret/data/common/package-publishing/aws-ecr-public/production/container-user-public access_key | ACCESS_KEY ;
/secret/data/common/package-publishing/aws-ecr-public/production/container-user-public access_key_id | ACCESS_KEY_ID ;
id: aws_secrets
- name: Configure AWS Credentials
uses: aws-actions/[email protected]
if: ${{ startsWith(github.ref, 'refs/tags') }}
with:
aws-access-key-id: ${{ env.ACCESS_KEY_ID }}
aws-secret-access-key: ${{ env.ACCESS_KEY }}
aws-region: us-east-1
- name: Login to Amazon ECR Public
if: ${{ startsWith(github.ref, 'refs/tags') }}
uses: aws-actions/amazon-ecr-login@v2
with:
registry-type: public
- name: Push image to ECR Public registry
if: ${{ startsWith(github.ref, 'refs/tags') }}
uses: akhilerm/[email protected]
with:
src: ${{ steps.meta.outputs.tags }}
dst: public.ecr.aws/s0t1h2z6/arcane/${{ github.event.repository.name }}:${{ steps.meta.outputs.version }}
# END AWS ECR Registry related steps