Skip to content

Upgrade GHA used actions #37

Upgrade GHA used actions

Upgrade GHA used actions #37

Workflow file for this run

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@v4
- name: Setup dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Build Project
run: dotnet build -c Release -o output APC
- name: Test Project
run: dotnet test --collect:"XPlat Code Coverage" APCTest
- name: Obtain Version
id: version
run: echo "number=$(./output/APC -- 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@v4
- name: Login to Dockerhub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to GHCR
uses: docker/login-action@v3
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@v5
with:
push: true
platforms: "linux/amd64,linux/arm64,linux/arm/v7"
build-args: |
BUILD_VERSION=${{ steps.build_version.outputs.number }}
tags: "mannkind/apc2mqtt:dev"
- name: Build and Push (Main)
if: github.ref == 'refs/heads/main'
uses: docker/build-push-action@v5
with:
push: true
platforms: "linux/amd64,linux/arm64,linux/arm/v7"
build-args: |
BUILD_VERSION=${{ steps.build_version.outputs.number }}
tags: "mannkind/apc2mqtt:latest,mannkind/apc2mqtt:${{ needs.build.outputs.version }},ghcr.io/mannkind/apc2mqtt:latest,ghcr.io/mannkind/apc2mqtt:${{ 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@v4
- name: Tag Revision
run: |
git tag -f ${{ needs.build.outputs.version }}
- name: Push Release
run: |
git push --tags