Skip to content

Commit

Permalink
ci: Revert pipelines back to working version where deployment listens…
Browse files Browse the repository at this point in the history
… for builds that have completed
  • Loading branch information
deadlydog committed Oct 2, 2023
1 parent b3924b3 commit af7abc4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 26 deletions.
8 changes: 0 additions & 8 deletions .github/workflows/build-and-test-powershell-module.yml
Original file line number Diff line number Diff line change
Expand Up @@ -261,11 +261,3 @@ jobs:
with:
name: ${{ env.deployFilesArtifactName }}
path: ${{ env.deployFilesArtifactDirectoryPath }}

trigger-deployment:
needs: build-and-test
# Only trigger a deployment if this build is for a push (not a PR) and is for the default branch (main).
if: github.event_name != 'pull_request' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
uses: ./.github/workflows/deploy-powershell-module.yml
with:
buildWorkflowRunId: ${{ fromJSON(github.run_id) }}
37 changes: 19 additions & 18 deletions .github/workflows/deploy-powershell-module.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,39 @@
name: deploy

on:
workflow_call:
workflow_run:
workflows: [build]
types: [completed]
branches: [main]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
buildWorkflowRunId:
description: 'The build workflow run ID containing the artifacts to use.'
required: true
workflowRunId:
description: 'The build workflow run ID containing the artifacts to use. The run ID can be found in the URL of the build workflow run.'
type: number

# # Allows you to run this workflow manually from the Actions tab
# workflow_dispatch:
# inputs:
# buildWorkflowRunId:
# description: 'The build workflow run ID containing the artifacts to use. The run ID can be found in the URL of the build workflow run.'
# required: true
# type: number
required: true

env:
powerShellModuleName: 'tiPS' # Must match the name in the build workflow.
prereleaseModuleArtifactName: 'PrereleaseModuleArtifact' # Must match the name in the build workflow.
stableModuleArtifactName: 'StableModuleArtifact' # Must match the name in the build workflow.
deployFilesArtifactName: 'DeployFilesArtifact' # Must match the name in the build workflow.
artifactsDirectoryPath: './artifacts'
workflowRunId: ${{ github.event_name == 'workflow_dispatch' && inputs.workflowRunId || github.event.workflow_run.id }} # Ternary operator to use input value if manually triggered, otherwise use the workflow_run.id value.

jobs:
publish-prerelease-module:
# Only run the deployment if manually triggered, or the build workflow succeeded.
if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
outputs:
prereleaseVersionNumber: ${{ steps.output-version-number.outputs.prereleaseVersionNumber }}
steps:
- name: Download prerelease module artifact from triggered workflow
uses: dawidd6/action-download-artifact@v2
with:
run_id: ${{ inputs.buildWorkflowRunId }}
run_id: ${{ env.workflowRunId }}
name: ${{ env.prereleaseModuleArtifactName}}
path: ${{ env.artifactsDirectoryPath }}
search_artifacts: true
Expand Down Expand Up @@ -84,7 +85,7 @@ jobs:
- name: Download deploy files artifact from triggered workflow
uses: dawidd6/action-download-artifact@v2
with:
run_id: ${{ inputs.buildWorkflowRunId }}
run_id: ${{ env.workflowRunId }}
name: ${{ env.deployFilesArtifactName}}
path: ${{ env.artifactsDirectoryPath }}
search_artifacts: true
Expand Down Expand Up @@ -127,7 +128,7 @@ jobs:
- name: Download deploy files artifact from triggered workflow
uses: dawidd6/action-download-artifact@v2
with:
run_id: ${{ inputs.buildWorkflowRunId }}
run_id: ${{ env.workflowRunId }}
name: ${{ env.deployFilesArtifactName}}
path: ${{ env.artifactsDirectoryPath }}
search_artifacts: true
Expand Down Expand Up @@ -160,7 +161,7 @@ jobs:
- name: Download stable module artifact from triggered workflow
uses: dawidd6/action-download-artifact@v2
with:
run_id: ${{ inputs.buildWorkflowRunId }}
run_id: ${{ env.workflowRunId }}
name: ${{ env.stableModuleArtifactName}}
path: ${{ env.artifactsDirectoryPath }}
search_artifacts: true
Expand Down Expand Up @@ -210,7 +211,7 @@ jobs:
- name: Download deploy files artifact from triggered workflow
uses: dawidd6/action-download-artifact@v2
with:
run_id: ${{ inputs.buildWorkflowRunId }}
run_id: ${{ env.workflowRunId }}
name: ${{ env.deployFilesArtifactName}}
path: ${{ env.artifactsDirectoryPath }}
search_artifacts: true
Expand Down Expand Up @@ -253,7 +254,7 @@ jobs:
- name: Download deploy files artifact from triggered workflow
uses: dawidd6/action-download-artifact@v2
with:
run_id: ${{ inputs.buildWorkflowRunId }}
run_id: ${{ env.workflowRunId }}
name: ${{ env.deployFilesArtifactName}}
path: ${{ env.artifactsDirectoryPath }}
search_artifacts: true
Expand Down

0 comments on commit af7abc4

Please sign in to comment.