forked from eccherda/ch552g_mini_keyboard
-
-
Notifications
You must be signed in to change notification settings - Fork 1
68 lines (60 loc) · 1.92 KB
/
ci.yaml
File metadata and controls
68 lines (60 loc) · 1.92 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
name: CI
on:
push:
branches:
- main
- renovate/*
paths:
- .github/workflows/ci.yaml
- src/**
pull_request:
branches: [ main ]
workflow_dispatch:
jobs:
build:
name: Build
runs-on: ubuntu-latest
outputs:
image_sha: ${{ steps.push_image.outputs.image_sha }}
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@2016bd2012dba4e32de620c46fe006a3ac9f0602 # v5
with:
dotnet-version: '10.0.x'
- name: Build solution
run: dotnet build --configuration Release
working-directory: src
- name: Run tests
run: dotnet test --no-build --configuration Release
working-directory: src
- name: Build Docker images
run: |
app="keypad-flasher"
echo "Building $app"
docker build -t $app -f "Keypad.Flasher.Server/Dockerfile" .
working-directory: src
- name: Push Docker images
id: push_image
run: |
echo $GITHUB_TOKEN | docker login ghcr.io --username AmyJeanes --password-stdin
app="keypad-flasher"
echo "Pushing $app"
docker tag $app ghcr.io/amyjeanes/keypad/$app:latest
docker push ghcr.io/amyjeanes/keypad/$app:latest
# Get the image SHA and set it as output
IMAGE_SHA=$(docker inspect --format='{{index .RepoDigests 0}}' ghcr.io/amyjeanes/keypad/$app:latest | cut -d'@' -f2)
echo "image_sha=$IMAGE_SHA" >> $GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
working-directory: src
if: github.ref == 'refs/heads/main'
deploy:
if: github.ref == 'refs/heads/main'
needs: build
name: Deploy
uses: ./.github/workflows/terraform.yaml
with:
runApply: true
image_sha: ${{ needs.build.outputs.image_sha }}
secrets: inherit