From 61e7237cd88e5ebf895cbaec5bd1738a5f7e81a9 Mon Sep 17 00:00:00 2001 From: Giovanny Hernandez <87216285+officialgio@users.noreply.github.com> Date: Wed, 13 Nov 2024 21:36:00 -0800 Subject: [PATCH 1/2] Added CI workflow --- .github/workflows/dotnet.yml | 84 ++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 .github/workflows/dotnet.yml diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml new file mode 100644 index 0000000..fbbe4c1 --- /dev/null +++ b/.github/workflows/dotnet.yml @@ -0,0 +1,84 @@ +# This workflow will build a .NET project +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net + +name: CICD + +on: + push: + branches: [ "main" ] + +jobs: + generate-version: + runs-on: ubuntu-latest + + permissions: # to publish the new tag to github + contents: write + + steps: + - uses: actions/checkout@v4 + - name: Github Tag Bump + id: tag_bump + uses: anothrNick/github-tag-action@1.67.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + INITIAL_VERSION: 1.0.2 # this comes from your Contracts pkg + DEFAULT_BUMP: patch # 1.0.x + + outputs: + new_version: ${{ steps.tag_bump.outputs.new_tag }} # store the generated tag + + + package-and-publish-contracts: + + runs-on: ubuntu-latest + needs: generate-version + + permissions: + contents: read + packages: write + + steps: + - uses: actions/checkout@v4 + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 7.0.x + source-url: https://nuget.pkg.github.com/${{github.repository_owner}}/index.json + env: + NUGET_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Pack + run: | + dotnet pack src/Play.Catalog.Contracts/ \ + --configuration Release \ + -p:PackageVersion=${{ needs.generate-version.outputs.new_version }} \ + -p:RepositoryUrl=https://github.com/${{github.repository_owner}}/play.catalog \ + -o packages + + - name: Publish + run: dotnet nuget push packages/*.nupkg + + # build docker image + build-and-deploy-service: + + runs-on: ubuntu-latest + needs: generate-version + + env: + APP_NAME: play-economy-microservices + + permissions: + contents: read + packages: write + + steps: + - uses: actions/checkout@v4 # checkout the latest code + + - name: Build and push Docker images + uses: docker/build-push-action@v6.9.0 + with: + # List of secrets to expose to the build (e.g., key=string, GIT_AUTH_TOKEN=mytoken) + secrets: | + "GH_OWNER=${{github.repository_owner}}" + "GH_PAT=${{secrets.GH_PAT}}" + tags: ${{env.APP_NAME}}.azurecr.io/play.catalog:${{ needs.generate-version.outputs.new_version }} From aa505fa17ab0f2a5c403c637fcfb083e672b92f9 Mon Sep 17 00:00:00 2001 From: Giovanny Hernandez <87216285+officialgio@users.noreply.github.com> Date: Wed, 13 Nov 2024 21:39:13 -0800 Subject: [PATCH 2/2] Rename dotnet.yml to cicd.yml --- .github/workflows/{dotnet.yml => cicd.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{dotnet.yml => cicd.yml} (100%) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/cicd.yml similarity index 100% rename from .github/workflows/dotnet.yml rename to .github/workflows/cicd.yml