diff --git a/.github/workflows/github_actions_test_v2.yml b/.github/workflows/github_actions_test_v2.yml new file mode 100644 index 000000000..b7ac1535d --- /dev/null +++ b/.github/workflows/github_actions_test_v2.yml @@ -0,0 +1,99 @@ +# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy +# More GitHub Actions for Azure: https://github.com/Azure/actions + +name: Build and deploy to Azure App Services + +on: + push: + branches: + - master + schedule: + - cron: "0 0/3 * * *" + +jobs: + build-and-deploy-dotnet-app: + runs-on: ubuntu-latest + + permissions: + id-token: write + + steps: + - uses: actions/checkout@v4 + + - name: Modify the sample app + run: | + cp -r ./__tests__/dotnetsampleapp dotnetapp + current_utc_time=$(date -u +"%Y-%m-%d %H:%M:%S %Z") + sed -i "s/<<>>/$current_utc_time/g" dotnetapp/Controllers/HelloController.cs + + echo "The placeholder has been replaced with current UTC time: $current_utc_time" + + - name: Set up .NET Core + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '8.x' + + - name: Build with dotnet + run: dotnet build --configuration Release dotnetapp/DOTNET_8_APP.csproj + + - name: dotnet publish + run: dotnet publish dotnetapp/DOTNET_8_APP.csproj -c Release -o myapp + + - name: Upload artifact for deployment job + uses: actions/upload-artifact@v4 + with: + name: .net-app + path: myapp + + - name: Deploy to Azure Web App + id: deploy-to-webapp + uses: azure/webapps-deploy@releases/v2 + with: + app-name: 'lwasv2-euap-dotnet-githubactionstest-v2' + slot-name: 'Production' + package: myapp + publish-profile: ${{ secrets.LWASV2_EUAP_DOTNET_GITHUBACTIONSTEST_V2 }} + + build-and-deploy-node-app: + runs-on: ubuntu-latest + + permissions: + id-token: write + + steps: + - uses: actions/checkout@v4 + + - name: modify Node.js App + run: | + cp -r ./__tests__/nodesampleapp nodeapp + current_utc_time=$(date -u +"%Y-%m-%d %H:%M:%S %Z") + sed -i "s/<<>>/$current_utc_time/g" nodeapp/server.js + + echo "The placeholder has been replaced with current UTC time: $current_utc_time" + + - name: Set up Node.js version + uses: actions/setup-node@v3 + with: + node-version: '20.x' + + - name: npm ci, build, and test + run: | + cd nodeapp + npm ci + npm run build --if-present + npm run test --if-present + + - name: Upload artifact for deployment job + uses: actions/upload-artifact@v4 + with: + name: node-app + path: nodeapp + + - name: 'Deploy to Azure Web App' + id: deploy-to-webapp + uses: azure/webapps-deploy@releases/v2 + with: + app-name: 'lwasv2-euap-node-githubactions-v2' + slot-name: 'Production' + package: nodeapp + publish-profile: ${{ secrets.LWASV2_EUAP_NODE_GITHUBACTIONS_V2 }} \ No newline at end of file diff --git a/.github/workflows/github_actions_test.yml b/.github/workflows/github_actions_test_v3.yml similarity index 97% rename from .github/workflows/github_actions_test.yml rename to .github/workflows/github_actions_test_v3.yml index 5b1261622..e914019d5 100644 --- a/.github/workflows/github_actions_test.yml +++ b/.github/workflows/github_actions_test_v3.yml @@ -54,7 +54,7 @@ jobs: - name: Deploy to Azure Web App id: deploy-to-webapp - uses: azure/webapps-deploy@v3 + uses: azure/webapps-deploy@releases/v3 with: app-name: 'lwasv2-euap-dotnet-githubactionstest' slot-name: 'Production' @@ -104,7 +104,7 @@ jobs: - name: 'Deploy to Azure Web App' id: deploy-to-webapp - uses: azure/webapps-deploy@v3 + uses: azure/webapps-deploy@releases/v3 with: app-name: 'lwasv2-euap-node-githubactions' slot-name: 'Production' diff --git a/.github/workflows/pr_check_windows_container_pubprofile.yml b/.github/workflows/pr_check_windows_container_pubprofile.yml index b40e143f9..6147f9bd9 100644 --- a/.github/workflows/pr_check_windows_container_pubprofile.yml +++ b/.github/workflows/pr_check_windows_container_pubprofile.yml @@ -97,4 +97,4 @@ jobs: with: app-name: ${{ env.AZURE_WEBAPP_NAME }} # Replace with your app name publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }} - images: ${{ env.CONTAINER_REGISTRY }}/containerwebapp/canaryreplica:latest + images: ${{ env.CONTAINER_REGISTRY }}/containerwebapp/canaryreplica:latest \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..fd9b06565 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,70 @@ +name: Release + +on: + workflow_dispatch: + inputs: + tag: + description: 'Tag to release or revert to (e.g., v3.2.1)' + required: true + type: string + revert: + description: 'Revert releases/vX to this existing tag?' + required: false + type: boolean + default: false + +jobs: + release: + runs-on: ubuntu-latest + permissions: + contents: write + + steps: + - name: Validate tag format + run: | + TAG="${{ inputs.tag }}" + if [[ ! "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "❌ Invalid tag format: $TAG. Expected: v.." + exit 1 + fi + + - name: Parse version + id: version + run: | + TAG="${{ inputs.tag }}" + MAJOR=$(echo "$TAG" | cut -d. -f1) + echo "major=${MAJOR}" >> $GITHUB_OUTPUT + echo "branch=releases/${MAJOR}" >> $GITHUB_OUTPUT + + - name: Checkout + uses: actions/checkout@v4 + with: + ref: ${{ inputs.revert == true && inputs.tag || steps.version.outputs.branch }} + fetch-depth: 0 + + - name: Configure Git + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + + - name: Release new tag + if: ${{ inputs.revert == false }} + run: | + MAJOR="${{ steps.version.outputs.major }}" + + # Update the major tag (e.g., v3) to point to same commit as inputs.tag + git tag -fa ${MAJOR} -m "Release ${{ inputs.tag }}" + git push origin ${MAJOR} --force + + echo "## ✅ Release ${{ inputs.tag }}" >> $GITHUB_STEP_SUMMARY + echo "- Tag: \`${{ inputs.tag }}\`" >> $GITHUB_STEP_SUMMARY + echo "- Branch: \`${{ steps.version.outputs.branch }}\`" >> $GITHUB_STEP_SUMMARY + + - name: Revert to existing tag + if: ${{ inputs.revert == true }} + run: | + BRANCH="${{ steps.version.outputs.branch }}" + git push origin ${{ inputs.tag }}:refs/heads/${BRANCH} --force + + echo "## ⏪ Reverted ${BRANCH} to ${{ inputs.tag }}" >> $GITHUB_STEP_SUMMARY + echo "- \`${BRANCH}\` now points to \`${{ inputs.tag }}\`" >> $GITHUB_STEP_SUMMARY \ No newline at end of file