diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 32fa05b..e05e3d4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,48 +1,34 @@ name: Build Management Pack -# Run when a pull request is closed +# When a push occurs to the dev or main branches on: - pull_request: + push: branches: - types: [closed] + - dev + - main # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: build: - # Only run when a pull request is merged to dev or main - if: | - ( github.event.pull_request.merged == true ) && - ( - ( github.base_ref == 'main' ) || - ( github.base_ref == 'dev' ) - ) + # Only run when a push occurs to dev or main + if: ( github.ref == 'refs/heads/main' ) || ( github.ref == 'refs/heads/dev' ) # Specify the version of Windows runs-on: windows-latest steps: # Check out the repository the pull request in merging into (dev/main) - #- name: Checkout Base Repo - # uses: actions/checkout@v2 - # with: - # github-token: ${{ secrets.AM_REPO_BUILD }} - # ref: ${{ github.event.pull_request.base.sha }} - # path: base - - - name: Checkout Head Repo + - name: Checkout Base Repo uses: actions/checkout@v2 with: - ref: ${{ github.event.pull_request.head.sha }} - repository: ${{ github.event.pull_request.head.repo.full_name }} - path: head + path: base + token: ${{ secrets.GITHUB_TOKEN }} # Execute the build PowerShell script - name: Execute build script - if: | - ( github.base_ref == 'main' ) || - ( ( github.base_ref == 'dev' ) && ( github.head_ref != 'main' ) ) + if: ( github.ref == 'refs/heads/main' ) || ( github.ref == 'refs/heads/dev' ) shell: powershell - run: .\head\Build\build.ps1 + run: .\base\Build\build.ps1 # Upload the management pack files as artifacts - name: Upload Artifacts @@ -53,7 +39,7 @@ jobs: # Create a release of the management pack - name: Generate Release - if: github.base_ref == 'main' + if: github.ref == 'refs/heads/main' uses: softprops/action-gh-release@v1 with: name: v${{ env.Version }} @@ -65,7 +51,7 @@ jobs: # Create a beta release of the management pack - name: Generate Beta Release - if: github.base_ref == 'dev' + if: github.ref == 'refs/heads/dev' uses: softprops/action-gh-release@v1 with: name: v${{ env.Version }} @@ -74,18 +60,3 @@ jobs: files: ${{ env.ArtifactFileName }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - # Open a pull request for dev <- main - - name: Open pull to commit into dev from main - if: ( github.base_ref == 'main' ) && ( github.head_ref == 'dev' ) - uses: peter-evans/create-pull-request@v3 - with: - path: head - commit-message: Update dev version to v${{ env.Version }} - committer: GitHub Actions Bot - author: GitHub Actions Bot - branch: main - delete-branch: false - base: dev - title: Rebase dev - body: Update dev to v${{ env.Version }} from main. diff --git a/Build/build.ps1 b/Build/build.ps1 index 721c9ab..2bdd8d3 100644 --- a/Build/build.ps1 +++ b/Build/build.ps1 @@ -1,8 +1,7 @@ # Set the verbose preference $VerbosePreference = 'Continue' -Write-Verbose -Message "GITHUB_BASE_REF: $($env:GITHUB_BASE_REF)" -Write-Verbose -Message "GITHUB_HEAD_REF: $($env:GITHUB_HEAD_REF)" +Write-Verbose -Message "GITHUB_REF: $($env:GITHUB_REF)" # Download the System Center Visual Studio Authoring Extensions (VSAE) $invokeWebRequestParams = @{ @@ -21,7 +20,7 @@ msiexec /quiet /i $vsaeMsiFile.FullName $vsWherePath = Join-Path -Path ( Join-Path -Path ( Join-Path -Path ${env:ProgramFiles(x86)} -ChildPath 'Microsoft Visual Studio' ) -ChildPath Installer ) -ChildPath vswhere.exe Write-Verbose -Message "vswhere.exe path: $vsWherePath" -$solutions = Get-ChildItem -Path Head -Filter *.sln -Recurse +$solutions = Get-ChildItem -Path base -Filter *.sln -Recurse Write-Verbose -Message ( "Solution Files: `n {0}" -f ( $solutions.FullName -join "`n " ) ) foreach ( $solution in $solutions ) @@ -114,7 +113,7 @@ foreach ( $solution in $solutions ) } # Verify the management pack files were created - $buildFiles = Get-ChildItem -Path .\head\*\bin\Release\* + $buildFiles = Get-ChildItem -Path .\base\*\bin\Release\* Write-Verbose -Message ( "Management Pack Files:`n {0}" -f ( $buildFiles.FullName -join "`n " ) ) # Find the relevant file to release @@ -133,7 +132,7 @@ foreach ( $solution in $solutions ) if ( -not $releaseFile ) { - throw 'No management pack files found in ".\head\*\bin\Release\*"' + throw 'No management pack files found in ".\base\*\bin\Release\*"' } else { @@ -146,12 +145,12 @@ foreach ( $solution in $solutions ) # Commit the version update to the reference repo Push-Location - Set-Location -Path head + Set-Location -Path base git config user.name "GitHub Actions Bot" git config user.email "" git add $projectFile.FullName git add $projectUserFile.FullName git commit -m $commitComment - git push + git push origin HEAD:$($env:GITHUB_REF) Pop-Location }