From b62df746994042ac6f76885f847be7aa5caa15df Mon Sep 17 00:00:00 2001 From: "Martin Hinshelwood nkdAgility.com" Date: Wed, 17 Jul 2024 09:23:54 +0100 Subject: [PATCH 1/7] feat(main.yml): add main branch and all tags to trigger conditions to extend CI/CD coverage feat(MigrationTools.sln): add triggertest.yml to solution for better project organization feat: add new triggertest.yml workflow for testing CI/CD triggers --- .github/workflows/main.yml | 4 +++- MigrationTools.sln | 1 + triggertest.yml | 25 +++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 triggertest.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 037896471..daf0491d3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -7,8 +7,10 @@ permissions: on: push: branches: - - "*" + - '*' + - main tags: + - '*' - '!v*-*' pull_request: branches: diff --git a/MigrationTools.sln b/MigrationTools.sln index 3852462fd..39f9bfc3c 100644 --- a/MigrationTools.sln +++ b/MigrationTools.sln @@ -94,6 +94,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".workflows", ".workflows", .github\workflows\main.yml = .github\workflows\main.yml .github\workflows\opencommit.yml = .github\workflows\opencommit.yml .github\workflows\stale.yml = .github\workflows\stale.yml + triggertest.yml = triggertest.yml EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MigrationTools.ConsoleDataGenerator", "src\MigrationTools.ConsoleDataGenerator\MigrationTools.ConsoleDataGenerator.csproj", "{6A259EA6-860B-448A-8943-594DC1A15105}" diff --git a/triggertest.yml b/triggertest.yml new file mode 100644 index 000000000..470149019 --- /dev/null +++ b/triggertest.yml @@ -0,0 +1,25 @@ +name: Trigger Test + +on: + push: + branches: + - '*' + - main + tags: + - '*' + - '!v*-*' + pull_request: + branches: + - main + workflow_dispatch: + + jobs: + Test: + name: "Test " + runs-on: ubuntu-latest + steps: + - name: "Test" + shell: pwsh + id: nkdagility + run: | + Write-Output "Hello World" \ No newline at end of file From 65cb9758c7a0789ce5d07075f713390b8e87be71 Mon Sep 17 00:00:00 2001 From: "Martin Hinshelwood nkdAgility.com" Date: Tue, 16 Jul 2024 17:18:17 +0100 Subject: [PATCH 2/7] fix(main.yml): replace GITHUB_TOKEN with NKD_MRHINSH_TOKEN in Winget Release script to use the correct authentication token --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index daf0491d3..a3927d67c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -381,7 +381,7 @@ jobs: - name: "Winget Release" shell: pwsh run: | - .\build\releaseWingetPackage.ps1 -version ${{ needs.Setup.outputs.GitVersion_SemVer }} -ring ${{needs.Setup.outputs.nkdAgility_Ring}} -GH_TOKEN ${{ secrets.GITHUB_TOKEN }} + .\build\releaseWingetPackage.ps1 -version ${{ needs.Setup.outputs.GitVersion_SemVer }} -ring ${{needs.Setup.outputs.nkdAgility_Ring}} -GH_TOKEN ${{ secrets.NKD_MRHINSH_TOKEN }} # Release to Docs DocsRelease: From 9a638733faac280c99642b4deea4d3ba20142e25 Mon Sep 17 00:00:00 2001 From: "Martin Hinshelwood nkdAgility.com" Date: Tue, 16 Jul 2024 17:23:54 +0100 Subject: [PATCH 3/7] fix(main.yml): correct choco push command by enclosing $chocoFile in quotes to ensure correct file path handling --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a3927d67c..761750031 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -359,7 +359,7 @@ jobs: Write-Output $"Running with {$chocoFile}" } - choco push $chocoFile.FullName --version $NuGetVersion --key ${{ secrets.CHOCO_APIKEY }} --source https://push.chocolatey.org/ + choco push "$chocoFile" --version $NuGetVersion --key ${{ secrets.CHOCO_APIKEY }} --source https://push.chocolatey.org/ # Release to Winget From 0456fb55ad32672f8adcabfb5cc67daa9debcf84 Mon Sep 17 00:00:00 2001 From: "Martin Hinshelwood nkdAgility.com" Date: Tue, 16 Jul 2024 17:29:37 +0100 Subject: [PATCH 4/7] feat(.github/workflows): add open-pr-describer.yml to generate PR descriptions using OpenAI feat(MigrationTools.sln): include open-pr-describer.yml in solution items for visibility and easy access --- .github/workflows/open-pr-describer.yml | 22 ++++++++++++++++++++++ MigrationTools.sln | 1 + 2 files changed, 23 insertions(+) create mode 100644 .github/workflows/open-pr-describer.yml diff --git a/.github/workflows/open-pr-describer.yml b/.github/workflows/open-pr-describer.yml new file mode 100644 index 000000000..5e5fa4e65 --- /dev/null +++ b/.github/workflows/open-pr-describer.yml @@ -0,0 +1,22 @@ +name: OpenAI PR Description Generator + +on: + pull_request: + types: + - opened + - synchronize + +permissions: + pull-requests: write + contents: read + +jobs: + pull-request: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: Ant0wan/openai-pr@v1 + with: + api-key: ${{ secrets.OPENAI_API_KEY }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/MigrationTools.sln b/MigrationTools.sln index 39f9bfc3c..3c1027118 100644 --- a/MigrationTools.sln +++ b/MigrationTools.sln @@ -92,6 +92,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".workflows", ".workflows", ProjectSection(SolutionItems) = preProject .github\workflows\code-review.yml = .github\workflows\code-review.yml .github\workflows\main.yml = .github\workflows\main.yml + .github\workflows\open-pr-describer.yml = .github\workflows\open-pr-describer.yml .github\workflows\opencommit.yml = .github\workflows\opencommit.yml .github\workflows\stale.yml = .github\workflows\stale.yml triggertest.yml = triggertest.yml From 104ed1e5f2c8d6ac1e4709d0e5df23dd80a8f685 Mon Sep 17 00:00:00 2001 From: "Martin Hinshelwood nkdAgility.com" Date: Tue, 16 Jul 2024 17:41:02 +0100 Subject: [PATCH 5/7] refactor(github workflows): replace env variables with secrets for app-id and private-key to enhance security remove(env): delete APP_ID and PRIVATE_KEY from main.yml as they are no longer needed after refactor --- .github/workflows/code-review.yml | 4 ++-- .github/workflows/main.yml | 8 ++------ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/code-review.yml b/.github/workflows/code-review.yml index e49834851..9bba61e62 100644 --- a/.github/workflows/code-review.yml +++ b/.github/workflows/code-review.yml @@ -15,8 +15,8 @@ jobs: - uses: actions/create-github-app-token@v1 id: app-token with: - app-id: ${{ env.APP_ID }} - private-key: ${{ env.PRIVATE_KEY }} + app-id: ${{ secrets.NKDAGILITY_BOT_APP_ID }} + private-key: ${{ secrets.NKDAGILITY_BOT_CLIENTSECRET }} - uses: fitomad/github-chatgpt-integration@main with: openai-api-key: ${{ secrets.OPENAI_API_KEY }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 761750031..6a912c307 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -21,10 +21,6 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true -env: - APP_ID: "Iv23li9aYvt0VW9x4Jhh" - PRIVATE_KEY: ${{ secrets.NKDAGILITY_BOT_CLIENTSECRET }} - defaults: run: shell: pwsh @@ -264,8 +260,8 @@ jobs: - uses: actions/create-github-app-token@v1 id: app-token with: - app-id: ${{ env.APP_ID }} - private-key: ${{ env.PRIVATE_KEY }} + app-id: ${{ secrets.NKDAGILITY_BOT_APP_ID }} + private-key: ${{ secrets.NKDAGILITY_BOT_CLIENTSECRET }} - name: "Package Files" shell: pwsh run: | From eaa89f0a8febc8a96a1550fc6fceb76f0f1ba235 Mon Sep 17 00:00:00 2001 From: "Martin Hinshelwood nkdAgility.com" Date: Tue, 16 Jul 2024 18:00:26 +0100 Subject: [PATCH 6/7] feat(main.yml): add new environment variables for tracking changes in src, docs, and automation fix(main.yml): modify release condition to check for changes in src and docs, ensuring releases only happen when relevant changes are made --- .github/workflows/main.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6a912c307..c93d2cb03 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -251,6 +251,9 @@ jobs: GitVersion_InformationalVersion: ${{ needs.Setup.outputs.GitVersion_InformationalVersion }} GitVersion_NuGetVersion: ${{ needs.Setup.outputs.GitVersion_NuGetVersion }} GitVersion_PreReleaseLabel: ${{ needs.Setup.outputs.GitVersion_PreReleaseLabel }} + HasChanged_src: ${{ needs.Setup.outputs.HasChanged_src }} + HasChanged_docs: ${{ needs.Setup.outputs.HasChanged_docs }} + HasChanged_automation: ${{ needs.Setup.outputs.HasChanged_automation }} needs: [build, Setup] if: ${{ success() && ( needs.Setup.outputs.nkdAgility_Ring != 'Canary' ) }} steps: @@ -270,7 +273,7 @@ jobs: id: release-options shell: pwsh run: | - if ($Env:nkdAgility_Ring -ne 'Canary') { + if ($Env:nkdAgility_Ring -ne 'Canary' && ($Env:HasChanged_src || $Env:HasChanged_docs )) { echo "discussion_category_name=Anouncement" >> $env:GITHUB_OUTPUT } - name: Release From 6fd5c453eb3c2cc48340e515f1d1be5139ee4465 Mon Sep 17 00:00:00 2001 From: "Martin Hinshelwood nkdAgility.com" Date: Wed, 17 Jul 2024 09:31:54 +0100 Subject: [PATCH 7/7] refactor(main.yml): simplify 'on' event triggers for push and pull_request actions fix(main.yml): use 'tags-ignore' instead of 'tags' to exclude certain tags from triggering the workflow --- .github/workflows/main.yml | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c93d2cb03..80a699ca6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -4,17 +4,13 @@ permissions: contents: read pull-requests: write -on: +on: push: - branches: - - '*' - - main - tags: - - '*' - - '!v*-*' + branches: ["*"] + tags-ignore: ["v*-*"] + pull_request: - branches: - - main + branches: [ "main" ] workflow_dispatch: concurrency: