Use self-hosted only for building images #77
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: self-hosted | |
container: | |
image: ubuntu:latest | |
permissions: | |
packages: write | |
steps: | |
# - name: Delete huge unnecessary tools folder | |
# run: rm -rf /opt/hostedtoolcache | |
- name: Install dependencies | |
run: | | |
apt update | |
apt install -y git curl | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 8.0.x | |
- 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: 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=max | |
- 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=max |