41 lines
1.1 KiB
YAML
41 lines
1.1 KiB
YAML
name: Build and Push Docker Image
|
|
|
|
on:
|
|
push:
|
|
branches: [ main ]
|
|
|
|
env:
|
|
REGISTRY: docker.astrocore.space
|
|
IMAGE_NAME: astrocore/astrocore-api
|
|
|
|
jobs:
|
|
build-and-push:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Setup .NET
|
|
uses: actions/setup-dotnet@v4
|
|
with:
|
|
dotnet-version: '8.0.x'
|
|
|
|
- name: Restore dependencies
|
|
run: dotnet restore Astrocore/Astrocore.Api/Astrocore.Api.csproj
|
|
|
|
- name: Build
|
|
run: dotnet build Astrocore/Astrocore.Api/Astrocore.Api.csproj -c Release --no-restore
|
|
|
|
- name: Publish
|
|
run: dotnet publish Astrocore/Astrocore.Api/Astrocore.Api.csproj -c Release -o out
|
|
|
|
- name: Log in to Docker Registry
|
|
run: echo "${{ secrets.DOCKER_REGISTRY_PASSWORD }}" | docker login ${{ env.REGISTRY }} -u ${{ secrets.DOCKER_REGISTRY_USERNAME }} --password-stdin
|
|
|
|
- name: Build Docker image
|
|
run: docker build -t $REGISTRY/$IMAGE_NAME:latest -f Astrocore/Astrocore.Api/Dockerfile .
|
|
|
|
- name: Push Docker image
|
|
run: docker push $REGISTRY/$IMAGE_NAME:latest
|