Skip to content

Commit

Permalink
Merge pull request #45 from deadlydog/RefactorCiCdFlow
Browse files Browse the repository at this point in the history
Have deploy workflow consume build workflow
  • Loading branch information
deadlydog authored Oct 22, 2023
2 parents d4facef + 79dbc0b commit 28849ca
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
19 changes: 3 additions & 16 deletions .github/workflows/build-and-test-powershell-module.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,19 @@
name: build

on:
push:
branches: [ "main" ]
paths: [ "src/**", "build/**", "deploy/**", ".github/workflows/**" ]
pull_request:
branches: [ "main" ]

# Allows you to run this workflow manually from the Actions tab
# Allows you to run this workflow manually from the Actions tab.
workflow_dispatch:

workflow_call:
inputs:
versionNumber:
description: 'The version number to use for the module. This should be in the format of "Major.Minor.Patch". e.g. "1.0.0". Future builds will increment from this version number. This input is optional. If not provided, the previous version numbers Patch will be incremented.'
required: false
type: string
default: ''
deploy:
description: 'Deploy the build artifacts. Only has effect when not building the main branch.'
required: false
type: boolean
default: false

env:
powerShellModuleName: 'tiPS' # Must match the name in the deployment workflow.
Expand Down Expand Up @@ -266,10 +260,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: inputs.deploy || (github.event_name != 'pull_request' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch))
uses: ./.github/workflows/deploy-powershell-module.yml
secrets: inherit
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
name: deploy

on:
workflow_call:
push:
branches: main
paths: [ "src/**", "build/**", "deploy/**", ".github/workflows/**" ]

# Allows you to run this workflow manually from the Actions tab.
workflow_dispatch:
inputs:
versionNumber:
description: 'The version number to use for the module. This should be in the format of "Major.Minor.Patch". e.g. "1.0.0". Future builds will increment from this version number. This input is optional. If not provided, the previous version numbers Patch will be incremented.'
required: false
type: string
default: ''

env:
powerShellModuleName: 'tiPS' # Must match the name in the build workflow.
Expand All @@ -11,7 +22,14 @@ env:
artifactsDirectoryPath: './artifacts'

jobs:
build-and-test:
uses: ./.github/workflows/build-and-test-powershell-module.yml
with:
versionNumber: ${{ github.event.inputs.versionNumber }}
secrets: inherit

publish-prerelease-module:
needs: build-and-test
runs-on: ubuntu-latest
outputs:
prereleaseVersionNumber: ${{ steps.output-version-number.outputs.prereleaseVersionNumber }}
Expand Down

0 comments on commit 28849ca

Please sign in to comment.