From bd0aa63a98ad3e065209159cef5101fefed527cf Mon Sep 17 00:00:00 2001 From: Andrew Polk Date: Wed, 20 Nov 2024 16:39:22 -0700 Subject: [PATCH] chore: GHA - another attempt to trigger Teamcity builds correctly --- .github/workflows/release.yml | 8 +- .github/workflows/trigger-teamcity-builds.yml | 90 ++++++++++--------- 2 files changed, 55 insertions(+), 43 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7bd00e3..8ca0b06 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,6 +9,8 @@ on: jobs: build-test-release: runs-on: ubuntu-latest + outputs: + new_release_published: ${{ steps.semantic_release.outputs.new_release_published }} steps: - name: Checkout code @@ -46,7 +48,11 @@ jobs: - name: Publish package id: semantic_release + uses: cycjimmy/semantic-release-action@v4 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - run: npx semantic-release + + - name: Output + run: | + echo "New Release Published: ${{ steps.semantic_release.outputs.new_release_published }}" diff --git a/.github/workflows/trigger-teamcity-builds.yml b/.github/workflows/trigger-teamcity-builds.yml index 28130ec..817d65d 100644 --- a/.github/workflows/trigger-teamcity-builds.yml +++ b/.github/workflows/trigger-teamcity-builds.yml @@ -1,47 +1,53 @@ name: Trigger TeamCity Builds on: - workflow_run: - workflows: ["Build-Test-Release"] - types: - - completed - workflow_dispatch: # Allows manual triggering + workflow_run: + workflows: ["Build-Test-Release"] + types: + - completed + workflow_dispatch: # Allows manual triggering jobs: - trigger-teamcity: - runs-on: ubuntu-latest - # Either a manual run or the Build-Test-Release workflow has completed successfully and a new release was published to npm - if: ${{ github.event_name == 'workflow_dispatch' || (github.event.workflow_run.conclusion == 'success' && (startsWith(github.event.workflow_run.head_commit.message, 'fix:') || startsWith(github.event.workflow_run.head_commit.message, 'feat:'))) }} - steps: - - name: Trigger TeamCity Build for alpha.bloomlibrary.org - uses: fjogeleit/http-request-action@v1 - with: - url: '${{ secrets.TEAMCITY_URL }}/app/rest/buildQueue' - method: 'POST' - contentType: 'application/json' - customHeaders: '{"Authorization": "Bearer ${{ secrets.TEAMCITY_TOKEN_RUN_BUILD }}"}' - data: '{"buildType": {"id": "Bloom_BloomLibraryOrg_BloomLibraryAlphaAlphaBloomlibraryOrgContinuous"}}' - - name: Trigger TeamCity Build for Bloom Reader Alpha - uses: fjogeleit/http-request-action@v1 - with: - url: '${{ secrets.TEAMCITY_URL }}/app/rest/buildQueue' - method: 'POST' - contentType: 'application/json' - customHeaders: '{"Authorization": "Bearer ${{ secrets.TEAMCITY_TOKEN_RUN_BUILD }}"}' - data: '{"buildType": {"id": "Bloom_BloomReader_BloomReaderMasterAlphaContinuousPublish"}}' - - name: Trigger TeamCity Build for Bloom Desktop Alpha - uses: fjogeleit/http-request-action@v1 - with: - url: '${{ secrets.TEAMCITY_URL }}/app/rest/buildQueue' - method: 'POST' - contentType: 'application/json' - customHeaders: '{"Authorization": "Bearer ${{ secrets.TEAMCITY_TOKEN_RUN_BUILD }}"}' - data: '{"buildType": {"id": "bt222"}}' - - name: Trigger TeamCity Build for dev-alpha.bloomlibrary.org - uses: fjogeleit/http-request-action@v1 - with: - url: '${{ secrets.TEAMCITY_URL }}/app/rest/buildQueue' - method: 'POST' - contentType: 'application/json' - customHeaders: '{"Authorization": "Bearer ${{ secrets.TEAMCITY_TOKEN_RUN_BUILD }}"}' - data: '{"buildType": {"id": "Bloom_BloomLibraryOrg_BloomLibrary2masterDevAlphaBloomlibraryOrgContinuous"}}' + trigger-teamcity: + runs-on: ubuntu-latest + # Run if manually triggered or if a new release was published + if: ${{ github.event_name == 'workflow_dispatch' || (github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.outputs.new_release_published == 'true') }} + steps: + - name: Workflow Inputs + run: | + echo "Event name: ${{ github.event_name }}" + echo "Workflow conclusion: ${{ github.event.workflow_run.conclusion }}" + echo "New release published: ${{ github.event.workflow_run.outputs.new_release_published }}" + + - name: Trigger TeamCity Build for alpha.bloomlibrary.org + uses: fjogeleit/http-request-action@v1 + with: + url: "${{ secrets.TEAMCITY_URL }}/app/rest/buildQueue" + method: "POST" + contentType: "application/json" + customHeaders: '{"Authorization": "Bearer ${{ secrets.TEAMCITY_TOKEN_RUN_BUILD }}"}' + data: '{"buildType": {"id": "Bloom_BloomLibraryOrg_BloomLibraryAlphaAlphaBloomlibraryOrgContinuous"}}' + - name: Trigger TeamCity Build for Bloom Reader Alpha + uses: fjogeleit/http-request-action@v1 + with: + url: "${{ secrets.TEAMCITY_URL }}/app/rest/buildQueue" + method: "POST" + contentType: "application/json" + customHeaders: '{"Authorization": "Bearer ${{ secrets.TEAMCITY_TOKEN_RUN_BUILD }}"}' + data: '{"buildType": {"id": "Bloom_BloomReader_BloomReaderMasterAlphaContinuousPublish"}}' + - name: Trigger TeamCity Build for Bloom Desktop Alpha + uses: fjogeleit/http-request-action@v1 + with: + url: "${{ secrets.TEAMCITY_URL }}/app/rest/buildQueue" + method: "POST" + contentType: "application/json" + customHeaders: '{"Authorization": "Bearer ${{ secrets.TEAMCITY_TOKEN_RUN_BUILD }}"}' + data: '{"buildType": {"id": "bt222"}}' + - name: Trigger TeamCity Build for dev-alpha.bloomlibrary.org + uses: fjogeleit/http-request-action@v1 + with: + url: "${{ secrets.TEAMCITY_URL }}/app/rest/buildQueue" + method: "POST" + contentType: "application/json" + customHeaders: '{"Authorization": "Bearer ${{ secrets.TEAMCITY_TOKEN_RUN_BUILD }}"}' + data: '{"buildType": {"id": "Bloom_BloomLibraryOrg_BloomLibrary2masterDevAlphaBloomlibraryOrgContinuous"}}'