Skip to content

Commit

Permalink
Merge pull request #21 from DFE-Digital/feature/197217-fix-nuget-pack…
Browse files Browse the repository at this point in the history
…age-deployment

Updated deploy and nuget package workflows to trigger the workflow by…
  • Loading branch information
FrostyApeOne authored Jan 27, 2025
2 parents a068422 + a103861 commit 94f797e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 18 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/build-and-push-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,21 @@ jobs:
} catch (error) {
core.setFailed(error.message);
}
- name: Trigger Build and Push NuGet Package workflow
uses: "actions/github-script@v7"
if: needs.set-env.outputs.environment == 'production'
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
script: |
const tagName = ${{ needs.set-env.outputs.release }}
console.log("Triggering Build and Push NuGet Package workflow with tag:", tagName);
await github.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: "build-and-push-package.yml",
ref: "main",
inputs: {
tag_name: tagName
}
});
30 changes: 12 additions & 18 deletions .github/workflows/build-and-push-package.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,29 @@
name: Build and Push NuGet Package

on:
workflow_run:
workflows: ["Deploy"]
types:
- completed
workflow_dispatch:
inputs:
tag_name:
description: "The production tag name to process"
required: true

env:
DOTNET_VERSION: '8.0.x'

jobs:
build-and-test:

# if: >
# github.event.workflow_run.conclusion == 'success' &&
# startsWith(github.event.workflow_run.ref, 'refs/tags/production-')
runs-on: ubuntu-latest
permissions:
packages: write
contents: write
if: startsWith(github.event.inputs.tag_name, 'production-')

steps:
- uses: actions/checkout@v4
- name: Check Out Tag
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
fetch-depth: 0 # Shallow clones disabled for a better relevancy of SC analysis

- name: Display Tag
run: echo "${{ github.event.workflow_run.head_commit.message }}"

- name: Debug Event Payload
run: echo "${{ toJson(github.event) }}"
ref: ${{ github.event.inputs.tag_name }}
fetch-depth: 0 # Ensure full history and tags are available

- name: Setup .NET
uses: actions/setup-dotnet@v4
Expand Down Expand Up @@ -92,7 +86,7 @@ jobs:
shell: /usr/bin/bash -e {0}

- name: Build, pack and publish
working-directory: Dfe.PersonsApi.Client
working-directory: src/Dfe.PersonsApi.Client
run: |
dotnet build -c Release
dotnet pack -c Release -p:PackageVersion=${{ env.NEW_VERSION }} --output .
Expand Down

0 comments on commit 94f797e

Please sign in to comment.