This repository has been archived by the owner on Jan 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
110 lines (96 loc) · 3.23 KB
/
main.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
name: Main Workflow
on:
push:
branches:
- main
workflow_dispatch:
inputs:
tag:
description: container image tag
default: dev
jobs:
build:
name: Build and Test
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.number }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.0.x'
- name: Build Project
run: dotnet build -c Release -o output LitterRobot
- name: Test Project
run: dotnet test --collect:"XPlat Code Coverage" LitterRobotTest
- name: Obtain Version
id: version
run: echo "number=$(./output/LitterRobot -- version)" >> $GITHUB_OUTPUT
- name: Upload coverage
run: bash <(curl -s https://codecov.io/bash)
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
containerize:
name: Upload Docker Images
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Login to Dockerhub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to GHCR
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Context for Buildx
id: buildx-context
run: |
docker context create builders
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
endpoint: builders
- name: Setup Build Version
id: build_version
run: |
BUILD_VERSION="${{ needs.build.outputs.version }}"
echo "number=${BUILD_VERSION:1}" >> $GITHUB_OUTPUT
- name: Build and Push (Dev)
if: github.event_name == 'workflow_dispatch'
uses: docker/build-push-action@v3
with:
push: true
platforms: "linux/amd64,linux/arm64,linux/arm/v7"
build-args: |
BUILD_VERSION=${{ steps.build_version.outputs.number }}
tags: "mannkind/litterrobot2mqtt:dev"
- name: Build and Push (Main)
if: github.ref == 'refs/heads/main'
uses: docker/build-push-action@v3
with:
push: true
platforms: "linux/amd64,linux/arm64,linux/arm/v7"
build-args: |
BUILD_VERSION=${{ steps.build_version.outputs.number }}
tags: "mannkind/litterrobot2mqtt:latest,mannkind/litterrobot2mqtt:${{ needs.build.outputs.version }},ghcr.io/mannkind/litterrobot2mqtt:latest,ghcr.io/mannkind/litterrobot2mqtt:${{ needs.build.outputs.version }}"
release:
name: Release
runs-on: ubuntu-latest
needs: [build, containerize]
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Tag Revision
run: |
git tag -f ${{ needs.build.outputs.version }}
- name: Push Release
run: |
git push --tags