From 816a1f2697a3f9d86cce6696e23452f78e45ae78 Mon Sep 17 00:00:00 2001 From: twerthi Date: Tue, 28 Nov 2023 11:35:57 -0800 Subject: [PATCH] Adding workflow using OIDC --- .github/workflows/dotnet-core-oidc.yml | 76 ++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 .github/workflows/dotnet-core-oidc.yml diff --git a/.github/workflows/dotnet-core-oidc.yml b/.github/workflows/dotnet-core-oidc.yml new file mode 100644 index 00000000..3223c67d --- /dev/null +++ b/.github/workflows/dotnet-core-oidc.yml @@ -0,0 +1,76 @@ +name: .NET Core + +on: + pull_request: + branches: [ master ] + schedule: + - cron: "0 09 * * *" + workflow_dispatch: + +jobs: + build: + permissions: + id-token: write + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Login to Octopus Deploy + uses: OctopusDeploy/login@v1 + with: + server: https://samples.octopus.app + service_account_id: dbd740a8-8458-43e7-87ff-8763a2a5db41 + - name: Set Version + run: echo "PACKAGE_VERSION=$(date +'%Y.%m.%d').$GITHUB_RUN_NUMBER" >> $GITHUB_ENV + - name: Setup .NET 6 + uses: actions/setup-dotnet@v1 + with: + dotnet-version: '6.0.x' + - name: Install dependencies + run: dotnet restore + - name: Build + run: dotnet build --configuration Release --no-restore + - name: Test + run: dotnet test --no-restore --verbosity normal + - name: Create artifacts folder + run: | + mkdir "$GITHUB_WORKSPACE/artifacts" + mkdir "$GITHUB_WORKSPACE/artifacts/OctopusSamples.OctoPetShop.Database" + mkdir "$GITHUB_WORKSPACE/artifacts/OctopusSamples.OctoPetShop.Web" + mkdir "$GITHUB_WORKSPACE/artifacts/OctopusSamples.OctoPetShop.ProductService" + mkdir "$GITHUB_WORKSPACE/artifacts/OctopusSamples.OctoPetShop.ShoppingCartService" + - name: Publish OctoPetShopDatabase + run: dotnet publish OctopusSamples.OctoPetShop.Database/OctopusSamples.OctoPetShop.Database.csproj --configuration Release --no-restore --output "$GITHUB_WORKSPACE/artifacts/OctopusSamples.OctoPetShop.Database" + - name: Publish OctoPetShopWeb + run: dotnet publish OctopusSamples.OctoPetShop.Web/OctopusSamples.OctoPetShop.Web.csproj --configuration Release --no-restore --output "$GITHUB_WORKSPACE/artifacts/OctopusSamples.OctoPetShop.Web" + - name: Publish OctoPetShopProductService + run: dotnet publish OctopusSamples.OctoPetShop.ProductService/OctopusSamples.OctoPetShop.ProductService.csproj --configuration Release --no-restore --output "$GITHUB_WORKSPACE/artifacts/OctopusSamples.OctoPetShop.ProductService" + - name: Publish OctoPetShopShoppingCartService + run: dotnet publish OctopusSamples.OctoPetShop.ShoppingCartService/OctopusSamples.OctoPetShop.ShoppingCartService.csproj --configuration Release --no-restore --output "$GITHUB_WORKSPACE/artifacts/OctopusSamples.OctoPetshop.ShoppingCartService" + - name: Install Octopus CLI + uses: OctopusDeploy/install-octopus-cli-action@v1.1.6 + with: + version: latest + - name: Package OctoPetShopDatabase + run: | + octo pack --id="OctoPetShop.Database" --format="Zip" --version="$PACKAGE_VERSION" --basePath="$GITHUB_WORKSPACE/artifacts/OctopusSamples.OctoPetShop.Database" --outFolder="$GITHUB_WORKSPACE/artifacts" + - name: Package OctoPetShopWeb + run: | + octo pack --id="OctoPetShop.Web" --format="Zip" --version="$PACKAGE_VERSION" --basePath="$GITHUB_WORKSPACE/artifacts/OctopusSamples.OctoPetShop.Web" --outFolder="$GITHUB_WORKSPACE/artifacts" + - name: Package OctoPetShopProductService + run: | + octo pack --id="OctoPetShop.ProductService" --format="Zip" --version="$PACKAGE_VERSION" --basePath="$GITHUB_WORKSPACE/artifacts/OctopusSamples.OctoPetShop.ProductService" --outFolder="$GITHUB_WORKSPACE/artifacts" + - name: Package OctoPetShopShoppingCartService + run: | + octo pack --id="OctoPetShop.ShoppingCartService" --format="Zip" --version="$PACKAGE_VERSION" --basePath="$GITHUB_WORKSPACE/artifacts/OctopusSamples.OctoPetshop.ShoppingCartService" --outFolder="$GITHUB_WORKSPACE/artifacts" + - name: Push OctoPetShop packages + uses: OctopusDeploy/push-package-action@v3 + with: + packages: "artifacts/OctoPetShop.Database.${{ env.PACKAGE_VERSION }}.zip,artifacts/OctoPetShop.Web.${{ env.PACKAGE_VERSION }}.zip,artifacts/OctoPetShop.ProductService.${{ env.PACKAGE_VERSION }}.zip,artifacts/OctoPetShop.ShoppingCartService.${{ env.PACKAGE_VERSION }}.zip" + space: ${{ secrets.OCTOPUSSERVER_SPACE }} + - name: Create and deploy release + uses: OctopusDeploy/create-release-action@v3 + with: + space: ${{ secrets.OCTOPUSSERVER_SPACE }} + project: "Octo Pet Shop" +# deploy_to: "Development" +# progress: true