diff --git a/.github/workflows/build-workflow.yml b/.github/workflows/build-workflow.yml new file mode 100644 index 00000000..d92a7488 --- /dev/null +++ b/.github/workflows/build-workflow.yml @@ -0,0 +1,67 @@ +# Builds, runs tests, publishes artifacts + +name: Build ForcesUnite + +on: push + +jobs: + build-api: + runs-on: windows-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up .NET Core + uses: actions/setup-dotnet@v1 + with: + dotnet-version: '7.0.x' + include-prerelease: true + + - name: Build with .NET + run: | + cd FU.API + dotnet build + shell: pwsh + + - name: Publish + run: | + cd FU.API + dotnet publish + shell: pwsh + + - name: Upload Artifacts + uses: actions/upload-artifact@v3 + with: + name: .net-app + path: D:\a\PalmettoProgrammers\PalmettoProgrammers\FU.API\FU.API\bin + + - name: Test + run: | + cd FU.API + dotnet test + shell: pwsh + + build-spa: + runs-on: windows-latest + + steps: + - uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: '14' + + - name: Install dependencies + run: | + cd FU.SPA + npm install + - name: Run linter + run: | + cd FU.SPA + npm run lint + - name: Check formatting + run: | + cd FU.SPA + npm run format-check + \ No newline at end of file diff --git a/.github/workflows/release-workflow.yml b/.github/workflows/release-workflow.yml new file mode 100644 index 00000000..62f5cf7c --- /dev/null +++ b/.github/workflows/release-workflow.yml @@ -0,0 +1,104 @@ +# Builds and deploys API and SPA to Azure + +name: Release + +on: + push: + branches: + - prod + +jobs: + build-api: + name: Build API Job + runs-on: windows-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up .NET Core + uses: actions/setup-dotnet@v1 + with: + dotnet-version: '7.0.x' + include-prerelease: true + + - name: Build with .NET + run: | + cd FU.API + dotnet build --configuration Release + shell: pwsh + + - name: Publish + run: | + cd FU.API + dotnet publish -c Release + - name: Upload Artifacts + uses: actions/upload-artifact@v3 + with: + name: .net-app + path: D:\a\PalmettoProgrammers\PalmettoProgrammers\FU.API\FU.API\bin + + deploy-api: + name: Deploy API Job + runs-on: windows-latest + needs: build-api + environment: + name: 'Production' + url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} + permissions: + id-token: write #This is required for requesting the JWT + + steps: + - name: Download Artifacts + uses: actions/download-artifact@v3 + with: + name: .net-app + + - name: Login to Azure + uses: azure/login@v1 + with: + client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_87D22017AF9A4422BFA98ED1ADF7422D }} + tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_1C7528FFBA32419CB7F9CE5531B3980E }} + subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_1AD9A60BDBC9485E80D6B3728DDF6729 }} + + - name: Deploy API + id: deploy-to-webapp + uses: azure/webapps-deploy@v2 + with: + app-name: 'fuapi' + slot-name: 'Production' + package: . + + build-and-deploy-spa: + name: Build & Deploy SPA Job + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + with: + submodules: true + lfs: false + + - name: Build and Deploy + id: builddeploy + uses: Azure/static-web-apps-deploy@v1 + with: + azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_JOLLY_GLACIER_0AE92C40F }} + repo_token: ${{ secrets.GITHUB_TOKEN }} + action: "upload" + app_location: "/FU.SPA" # App source code path + output_location: "dist" + + comment: + name: Comment on Merge Request + runs-on: ubuntu-latest + needs: [deploy-api, build-and-deploy-spa] + + steps: + - uses: actions/checkout@v4 + + - name: Comment on Merge Request + run: | + branch_name=$(echo "${{ github.event.head_ref }}" | sed 's/refs\/heads\///') + gh pr comment $branch_name -b "Deployed to https://jolly-glacier-0ae92c40f.4.azurestaticapps.net/" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file