From 19117b37461b88fecdbbe61bd1288fe0bf75f9e7 Mon Sep 17 00:00:00 2001 From: Felipe Cotti Date: Tue, 29 Oct 2024 20:24:43 -0300 Subject: [PATCH] Let's try adding CI/CD here. --- .github/workflows/main.yml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..e331022 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,36 @@ +name: CI/CD + +on: + push: + branches: + - main + - '**' + +jobs: + build-and-test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '8.0.x' + + - name: Restore dependencies + run: dotnet restore src/Guestbooky/Guestbooky.sln + + - name: Run unit tests + run: dotnet test tests/Guestbooky.UnitTests/Guestbooky.UnitTests.csproj + + - name: Build/push Docker image (main) + if: github.ref == 'refs/heads/main' + uses: docker/build-push-action@v6.9 + with: + context: . + push: true + tags: cotti/guestbooky-be:latest + env: + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} \ No newline at end of file