-
Notifications
You must be signed in to change notification settings - Fork 0
79 lines (65 loc) · 2.01 KB
/
api.yml
File metadata and controls
79 lines (65 loc) · 2.01 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
name: API
on:
push:
branches: [master]
paths: ['src/api/**']
workflow_dispatch:
permissions:
id-token: write
packages: write
contents: read
concurrency:
group: api-${{ github.ref }}
cancel-in-progress: true
jobs:
build-and-deploy:
runs-on: ubuntu-latest
environment: production
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'
- uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: nuget-${{ runner.os }}-${{ hashFiles('src/api/**/*.csproj') }}
restore-keys: nuget-${{ runner.os }}-
- run: dotnet restore
working-directory: src/api
- run: dotnet build --no-restore --configuration Release
working-directory: src/api
- run: dotnet test --no-build --configuration Release
working-directory: src/api
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/metadata-action@v5
id: meta
with:
images: ghcr.io/networg/agentbox-api
tags: |
type=raw,value=latest
type=sha,prefix=,format=short
- uses: docker/build-push-action@v6
with:
context: src/api
platforms: linux/amd64
push: true
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
- uses: azure/login@v2
with:
client-id: ${{ vars.AZURE_CLIENT_ID }}
tenant-id: ${{ vars.AZURE_TENANT_ID }}
subscription-id: ${{ vars.AZURE_SUBSCRIPTION_ID }}
- run: |
SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-7)
az containerapp update \
--name ${{ vars.API_CONTAINER_APP_NAME }} \
--resource-group agentbox \
--image ghcr.io/networg/agentbox-api:${SHORT_SHA}