Skip to content

Commit

Permalink
Added CI workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
officialgio authored Nov 14, 2024
1 parent 4e8e91e commit 61e7237
Showing 1 changed file with 84 additions and 0 deletions.
84 changes: 84 additions & 0 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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/[email protected]
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 }}

0 comments on commit 61e7237

Please sign in to comment.