Skip to content

Update compile_upload.yml #22

Update compile_upload.yml

Update compile_upload.yml #22

name: Build
on:
schedule:
- cron: '15 2 8/14 * *' # Runs on the 8th day, repeat every 14 days at 02:15 (prevent 00:00 as capacity of Github might be reduced)
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
outputs:
packages_updated: ${{ steps.check_packages.outputs.packages_updated }} # Reference the output here
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.x
- name: Install dotnet-outdated
run: dotnet tool install --global dotnet-outdated-tool
- name: Update NuGet Packages
id: check_packages # Give this step an ID to reference its outputs
run: |
dotnet outdated --upgrade
if [ -n "$(git status --porcelain)" ]; then
echo "Packages updated."
echo "PACKAGES_UPDATED=true" >> $GITHUB_ENV
echo "packages_updated=true" >> $GITHUB_OUTPUT # Set environment variable
else
echo "No package updates."
echo "PACKAGES_UPDATED=false" >> $GITHUB_ENV
echo "packages_updated=false" >> $GITHUB_OUTPUT # Set environment variable
fi
- name: Commit and Push Changes
if: ${{ env.PACKAGES_UPDATED == 'true' }} # Use outputs for the condition
run: |
git config --global user.name "GitHub Action"
git config --global user.email "[email protected]"
git add .
git commit -m "Update NuGet packages"
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Restore dependencies
if: ${{ env.PACKAGES_UPDATED == 'true' }} # Use outputs for the condition
run: dotnet restore
- name: Build
if: ${{ env.PACKAGES_UPDATED == 'true' }} # Use outputs for the condition
run: dotnet build --no-restore
- name: Test
if: ${{ env.PACKAGES_UPDATED == 'true' }} # Use outputs for the condition
run: dotnet test --no-build --verbosity normal
publish:
needs: build
if: ${{ needs.build.outputs.packages_updated == 'true' }} # Only run if packages were updated
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build the Docker image
run: docker build -t dewitauto/synoai-fork:latest SynoAI
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Publish the Docker image
run: docker push dewitauto/synoai-fork:latest