Skip to content

Merge pull request #76 from MattJeanes/renovate/actions-setup-dotnet-4.x #130

Merge pull request #76 from MattJeanes/renovate/actions-setup-dotnet-4.x

Merge pull request #76 from MattJeanes/renovate/actions-setup-dotnet-4.x #130

Workflow file for this run

name: CI
on:
push:
branches: [ main ]
tags:
- 'v*'
pull_request:
branches: [ main ]
workflow_dispatch: {}
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@3e891b0cb619bf60e2c25674b222b8940e2c1c25 # v4
with:
dotnet-version: '9.0.x'
- name: Set variables
id: variables
run: |
VERSION=${GITHUB_REF#refs/tags/}
echo VERSION=$VERSION >> $GITHUB_OUTPUT
- name: Test project
run: |
dotnet test ./TeslaMateAgile.Tests/TeslaMateAgile.Tests.csproj
- name: Build project
run: |
dotnet publish ./TeslaMateAgile/TeslaMateAgile.csproj --self-contained true --runtime linux-x64 --output ./output/TeslaMateAgile-linux-x64
dotnet publish ./TeslaMateAgile/TeslaMateAgile.csproj --self-contained true --runtime linux-arm64 --output ./output/TeslaMateAgile-linux-arm64
dotnet publish ./TeslaMateAgile/TeslaMateAgile.csproj --self-contained true --runtime linux-arm --output ./output/TeslaMateAgile-linux-arm
dotnet publish ./TeslaMateAgile/TeslaMateAgile.csproj --self-contained true --runtime win-x64 --output ./output/TeslaMateAgile-win-x64
- name: Build Docker images
run: |
for appname in TeslaMateAgile; do
app=`echo $appname | tr '[:upper:]' '[:lower:]'`
echo "Building $appname docker amd64"
docker build -t $app:amd64 -f "$appname/Dockerfile" . --build-arg arch=bookworm-slim-amd64
echo "Building $appname docker arm32v7"
docker build -t $app:arm32v7 -f "$appname/Dockerfile" . --build-arg arch=bookworm-slim-arm32v7
echo "Building $appname docker arm64v8"
docker build -t $app:arm64v8 -f "$appname/Dockerfile" . --build-arg arch=bookworm-slim-arm64v8
done
- name: Upload a Build Artifact
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4
with:
name: TeslaMateAgile-linux-x64
path: ./output/TeslaMateAgile-linux-x64
- name: Upload a Build Artifact
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4
with:
name: TeslaMateAgile-linux-arm64
path: ./output/TeslaMateAgile-linux-arm64
- name: Upload a Build Artifact
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4
with:
name: TeslaMateAgile-linux-arm
path: ./output/TeslaMateAgile-linux-arm
- name: Upload a Build Artifact
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4
with:
name: TeslaMateAgile-win-x64
path: ./output/TeslaMateAgile-win-x64
- name: Push Docker images
run: |
echo $DOCKER_PASSWORD | docker login --username $DOCKER_USERNAME --password-stdin
for appname in TeslaMateAgile; do
app=`echo $appname | tr '[:upper:]' '[:lower:]'`
echo "Deploying $appname"
for arch in amd64 arm32v7 arm64v8; do
docker tag $app:$arch $DOCKER_USERNAME/$app:latest-$arch
docker tag $app:$arch $DOCKER_USERNAME/$app:$VERSION-$arch
done
versions=($VERSION)
if [[ $VERSION =~ "-" ]]; then
echo "Pre-release version detected, not setting latest tag"
else
versions+=("latest")
echo "Adding latest tag"
fi
for ver in "${versions[@]}"; do
echo "Deploying version $ver"
for arch in amd64 arm32v7 arm64v8; do
echo "Pushing docker tag $ver-arch"
docker push $DOCKER_USERNAME/$app:$ver-$arch
done
docker manifest create $DOCKER_USERNAME/$app:$ver $DOCKER_USERNAME/$app:$ver-amd64 $DOCKER_USERNAME/$app:$ver-arm32v7 $DOCKER_USERNAME/$app:$ver-arm64v8
docker manifest annotate $DOCKER_USERNAME/$app:$ver $DOCKER_USERNAME/$app:$ver-amd64 --os linux --arch amd64
docker manifest annotate $DOCKER_USERNAME/$app:$ver $DOCKER_USERNAME/$app:$ver-arm32v7 --os linux --arch arm
docker manifest annotate $DOCKER_USERNAME/$app:$ver $DOCKER_USERNAME/$app:$ver-arm64v8 --os linux --arch arm64
docker manifest push $DOCKER_USERNAME/$app:$ver
done
done
env:
DOCKER_USERNAME: ${{ vars.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
DOCKER_CLI_EXPERIMENTAL: enabled
VERSION: ${{ steps.variables.outputs.VERSION }}
if: startsWith(github.ref, 'refs/tags/')
- name: Zip project
run: |
cd ./output/TeslaMateAgile-linux-x64
zip -r ../TeslaMateAgile-linux-x64.zip .
cd ../TeslaMateAgile-linux-arm64
zip -r ../TeslaMateAgile-linux-arm64.zip .
cd ../TeslaMateAgile-linux-arm
zip -r ../TeslaMateAgile-linux-arm.zip .
cd ../TeslaMateAgile-win-x64
zip -r ../TeslaMateAgile-win-x64.zip .
cd ../../
if: startsWith(github.ref, 'refs/tags/')
- name: Create Release
uses: softprops/action-gh-release@e7a8f85e1c67a31e6ed99a94b41bd0b71bbee6b8 # v2
with:
name: Release ${{ github.ref_name }}
draft: true
prerelease: false
files: output/*.zip
if: startsWith(github.ref, 'refs/tags/')
deploy:
if: github.event_name != 'pull_request'
name: Deploy
runs-on: ubuntu-latest
needs: [build]
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
- name: Azure Login
uses: Azure/login@cb79c773a3cfa27f31f25eb3f677781210c9ce3d # v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Login to Kubernetes
uses: Azure/aks-set-context@4edaee69f820359371ee8bc85189ac03a21d3a58 # v3
with:
resource-group: abyss
cluster-name: abyss
- run: echo "${{ secrets.ABYSS_VALUES_FILE }}" | base64 --decode > abyss.values.yaml
- name: Install TeslaMateAgile
run: |
helm upgrade --install --wait --atomic \
teslamateagile ./charts/teslamateagile \
--namespace default \
--values abyss.values.yaml