Optimize building #106
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: .NET | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 8.0.x | |
- name: Restore dependencies | |
run: dotnet restore | |
- name: Build | |
run: dotnet build --no-restore | |
- name: Test | |
run: dotnet test --no-build --verbosity normal | |
publish: | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
needs: test | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write | |
steps: | |
- name: Delete huge unnecessary tools folder | |
run: rm -rf /opt/hostedtoolcache | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Check if checked runtime changed | |
uses: dorny/paths-filter@v3 | |
id: checkedruntime | |
with: | |
filters: | | |
checkedruntime: | |
- 'Backend/Sandbox/CheckedRuntime/**' | |
- name: Build and push checked runtime | |
if: steps.checkedruntime.outputs.checkedruntime == 'true' | |
uses: docker/bake-action@v5 | |
with: | |
source: . | |
workdir: Backend/Sandbox/CheckedRuntime | |
push: true | |
set: | | |
*.platform=linux/amd64,linux/arm64 | |
*.cache-from=type=gha | |
*.cache-to=type=gha,mode=min | |
- name: Build and push bot | |
uses: docker/bake-action@v5 | |
with: | |
source: . | |
workdir: Bot | |
push: true | |
set: | | |
*.platform=linux/amd64,linux/arm64 | |
*.cache-from=type=gha | |
*.cache-to=type=gha,mode=min | |
- name: Set MINUS_PREFIXED_PLATFORM_IF_NOT_AMD64 | |
run: | | |
MINUS_PREFIXED_PLATFORM_IF_NOT_AMD64=${{ runner.arch != 'X64' && format('-{0}', runner.arch) || '' }} | |
echo "MINUS_PREFIXED_PLATFORM_IF_NOT_AMD64=${MINUS_PREFIXED_PLATFORM_IF_NOT_AMD64,,}" >>${GITHUB_ENV} | |
- name: Build and push backend | |
uses: docker/bake-action@v5 | |
with: | |
source: . | |
workdir: Backend | |
push: true | |
set: | | |
*.platform=linux/amd64,linux/arm64 | |
*.cache-from=type=gha | |
*.cache-to=type=gha,mode=min | |
asm.args.MINUS_PREFIXED_PLATFORM_IF_NOT_AMD64=${{ env.MINUS_PREFIXED_PLATFORM_IF_NOT_AMD64 }} |