From c27d22e4df10335c2ef5d47092e584eb5f5bba24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Derriey?= Date: Sat, 17 Dec 2022 18:04:15 +0100 Subject: [PATCH 1/7] Reusable workflows must be in the `.github/workflows` directory --- .../README.md | 0 .../update-carter-package-references}/run.ps1 | 0 .../workflow-call.yml | 22 +++++++++++++++++++ .../workflow.yml | 2 +- 4 files changed, 23 insertions(+), 1 deletion(-) rename {update-carter-package-references => .github/workflows/update-carter-package-references}/README.md (100%) rename {update-carter-package-references => .github/workflows/update-carter-package-references}/run.ps1 (100%) create mode 100644 .github/workflows/update-carter-package-references/workflow-call.yml rename {update-carter-package-references => .github/workflows/update-carter-package-references}/workflow.yml (98%) diff --git a/update-carter-package-references/README.md b/.github/workflows/update-carter-package-references/README.md similarity index 100% rename from update-carter-package-references/README.md rename to .github/workflows/update-carter-package-references/README.md diff --git a/update-carter-package-references/run.ps1 b/.github/workflows/update-carter-package-references/run.ps1 similarity index 100% rename from update-carter-package-references/run.ps1 rename to .github/workflows/update-carter-package-references/run.ps1 diff --git a/.github/workflows/update-carter-package-references/workflow-call.yml b/.github/workflows/update-carter-package-references/workflow-call.yml new file mode 100644 index 0000000..65cf167 --- /dev/null +++ b/.github/workflows/update-carter-package-references/workflow-call.yml @@ -0,0 +1,22 @@ +# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json +name: Update Carter NuGet package references + +on: + workflow_dispatch: + inputs: + includePrerelease: + type: boolean + default: false + description: Whether to include prerelease versions when searching for the latest version of the Carter NuGet package + + commitAndPush: + type: boolean + default: false + description: Whether to commit and push the changes; Useful to test the process by looking at the resulting Git diff + +jobs: + update-carter-package-references: + uses: CarterCommunity/.github/workflows/update-carter-package-references/workflow.yml@mderriey/reusable-workflows + with: + includePrerelease: ${{ github.event.inputs.includePrerelease }} + commitAndPush: ${{ github.event.inputs.commitAndPush }} diff --git a/update-carter-package-references/workflow.yml b/.github/workflows/update-carter-package-references/workflow.yml similarity index 98% rename from update-carter-package-references/workflow.yml rename to .github/workflows/update-carter-package-references/workflow.yml index 3599931..9e69b5b 100644 --- a/update-carter-package-references/workflow.yml +++ b/.github/workflows/update-carter-package-references/workflow.yml @@ -2,7 +2,7 @@ name: Update Carter NuGet package references on: - workflow_dispatch: + workflow_call: inputs: includePrerelease: type: boolean From 21fe648d181b04e167fdb254ea7441edf9c91a81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Derriey?= Date: Sat, 17 Dec 2022 18:13:19 +0100 Subject: [PATCH 2/7] Try something else --- .../workflows/{update-carter-package-references => }/workflow.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{update-carter-package-references => }/workflow.yml (100%) diff --git a/.github/workflows/update-carter-package-references/workflow.yml b/.github/workflows/workflow.yml similarity index 100% rename from .github/workflows/update-carter-package-references/workflow.yml rename to .github/workflows/workflow.yml From a68a696c337984c95a9309ae5024b4207111784c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Derriey?= Date: Sat, 17 Dec 2022 18:16:55 +0100 Subject: [PATCH 3/7] Another try --- .github/workflows/workflow.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 9e69b5b..46984bd 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -5,13 +5,13 @@ on: workflow_call: inputs: includePrerelease: + required: true type: boolean - default: false description: Whether to include prerelease versions when searching for the latest version of the Carter NuGet package commitAndPush: + required: true type: boolean - default: false description: Whether to commit and push the changes; Useful to test the process by looking at the resulting Git diff jobs: From c319189f27426f2a5755eff431fa751eef0546b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Derriey?= Date: Sat, 17 Dec 2022 18:18:51 +0100 Subject: [PATCH 4/7] Slightly different syntax for inputs --- .github/workflows/workflow.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 46984bd..79159fb 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -35,14 +35,14 @@ jobs: run: >- .github/update-carter-package-references/run.ps1 -RootDirectory (Join-Path -Path $env:GITHUB_WORKSPACE -ChildPath 'self') - -IncludePrerelease:$${{ github.event.inputs.includePrerelease }} + -IncludePrerelease:$${{ inputs.includePrerelease }} shell: pwsh - name: Show Git diff run: git diff # https://github.com/marketplace/actions/checkout#push-a-commit-using-the-built-in-token - - if: github.event.inputs.commitAndPush + - if: inputs.commitAndPush name: Commit changes and push if necessary run: | GIT_CHANGES=$(git status --porcelain) From 0439a4a6db5df9173aa68f9eb4c36951a009f3e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Derriey?= Date: Sat, 17 Dec 2022 18:21:39 +0100 Subject: [PATCH 5/7] More adjustments --- .github/workflows/workflow.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 79159fb..12b8598 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -39,11 +39,13 @@ jobs: shell: pwsh - name: Show Git diff + working-directory: self run: git diff # https://github.com/marketplace/actions/checkout#push-a-commit-using-the-built-in-token - if: inputs.commitAndPush name: Commit changes and push if necessary + working-directory: self run: | GIT_CHANGES=$(git status --porcelain) if [ "$GIT_CHANGES" == "" ]; then From ccb853daa98ef20f478d5eccda325a179ad015ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Derriey?= Date: Sun, 18 Dec 2022 08:58:45 +0100 Subject: [PATCH 6/7] Tidy things up --- ... update-carter-nuget-package-references.yml} | 0 .../update-carter-package-references/README.md | 10 ---------- README.md | 2 +- update-carter-package-references/README.md | 17 +++++++++++++++++ .../run.ps1 | 0 .../workflow.yml | 2 +- 6 files changed, 19 insertions(+), 12 deletions(-) rename .github/workflows/{workflow.yml => update-carter-nuget-package-references.yml} (100%) delete mode 100644 .github/workflows/update-carter-package-references/README.md create mode 100644 update-carter-package-references/README.md rename {.github/workflows/update-carter-package-references => update-carter-package-references}/run.ps1 (100%) rename .github/workflows/update-carter-package-references/workflow-call.yml => update-carter-package-references/workflow.yml (86%) diff --git a/.github/workflows/workflow.yml b/.github/workflows/update-carter-nuget-package-references.yml similarity index 100% rename from .github/workflows/workflow.yml rename to .github/workflows/update-carter-nuget-package-references.yml diff --git a/.github/workflows/update-carter-package-references/README.md b/.github/workflows/update-carter-package-references/README.md deleted file mode 100644 index aadac88..0000000 --- a/.github/workflows/update-carter-package-references/README.md +++ /dev/null @@ -1,10 +0,0 @@ -## Update Carter NuGet package references - -The files in this directory can help set up a workflow in other repositories to update references to the Carter NuGet package. - -### Steps - -1. Create a new branch in the target repository. -1. Copy the [`workflow.yml`](./workflow.yml) file in this directory as the `.github/workflows/update-carter-package-references.yml` file in the target repository. -1. Open a pull request. -1. When merged, you will find a new action in the target repository. diff --git a/README.md b/README.md index e1e5933..9b97de5 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ## Reusable bits -This repository contains actions that can be reused in other repositories. +This repository contains actions and workflows that can be reused in other repositories. It currently includes: diff --git a/update-carter-package-references/README.md b/update-carter-package-references/README.md new file mode 100644 index 0000000..9898298 --- /dev/null +++ b/update-carter-package-references/README.md @@ -0,0 +1,17 @@ +## Update Carter NuGet package references + +The files in this directory can help set up a workflow in other repositories to update references to the Carter NuGet package. + +### Steps + +1. Create a new branch in the target repository. +1. Copy the [`workflow.yml`](./workflow.yml) file in this directory to the `.github/workflows` directory in the target repository. +1. Open a pull request. +1. When merged, you will find a new action in the target repository. + +### How it works + +This process takes advantage of [reusable workflows in GitHub Actions](https://docs.github.com/en/actions/using-workflows/reusing-workflows), which avoids having to duplicate logic across several repositories. + +The workflow defined in the `workflow.yml` file calls the workflow located in the [`.github/workflows/update-carter-nuget-package-references.yml`](../.github/workflows/update-carter-nuget-package-references.yml) file in this repository, which contains all the logic. +If in the future, we need to make adjustments to the logic, we'll only have to update a single file, instead of having to go through all the repositories where we might have copied that logic. diff --git a/.github/workflows/update-carter-package-references/run.ps1 b/update-carter-package-references/run.ps1 similarity index 100% rename from .github/workflows/update-carter-package-references/run.ps1 rename to update-carter-package-references/run.ps1 diff --git a/.github/workflows/update-carter-package-references/workflow-call.yml b/update-carter-package-references/workflow.yml similarity index 86% rename from .github/workflows/update-carter-package-references/workflow-call.yml rename to update-carter-package-references/workflow.yml index 65cf167..74836c0 100644 --- a/.github/workflows/update-carter-package-references/workflow-call.yml +++ b/update-carter-package-references/workflow.yml @@ -16,7 +16,7 @@ on: jobs: update-carter-package-references: - uses: CarterCommunity/.github/workflows/update-carter-package-references/workflow.yml@mderriey/reusable-workflows + uses: CarterCommunity/.github/.github/workflows/update-carter-package-references.yml@main with: includePrerelease: ${{ github.event.inputs.includePrerelease }} commitAndPush: ${{ github.event.inputs.commitAndPush }} From aae991163efaf2f1acf71534bb8a8e80bd92aee2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Derriey?= Date: Sun, 18 Dec 2022 17:40:20 +0100 Subject: [PATCH 7/7] Update repo name --- .../workflows/update-carter-nuget-package-references.yml | 8 ++++---- update-carter-package-references/workflow.yml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/update-carter-nuget-package-references.yml b/.github/workflows/update-carter-nuget-package-references.yml index 12b8598..fef9596 100644 --- a/.github/workflows/update-carter-nuget-package-references.yml +++ b/.github/workflows/update-carter-nuget-package-references.yml @@ -25,15 +25,15 @@ jobs: with: path: self - - name: Check out the CarterCommunity/.github repository + - name: Check out the CarterCommunity/build repository uses: actions/checkout@v3 with: - repository: CarterCommunity/.github - path: .github + repository: CarterCommunity/build + path: build - name: Update package references with latest version from NuGet run: >- - .github/update-carter-package-references/run.ps1 + build/update-carter-package-references/run.ps1 -RootDirectory (Join-Path -Path $env:GITHUB_WORKSPACE -ChildPath 'self') -IncludePrerelease:$${{ inputs.includePrerelease }} shell: pwsh diff --git a/update-carter-package-references/workflow.yml b/update-carter-package-references/workflow.yml index 74836c0..0097935 100644 --- a/update-carter-package-references/workflow.yml +++ b/update-carter-package-references/workflow.yml @@ -16,7 +16,7 @@ on: jobs: update-carter-package-references: - uses: CarterCommunity/.github/.github/workflows/update-carter-package-references.yml@main + uses: CarterCommunity/build/.github/workflows/update-carter-package-references.yml@main with: includePrerelease: ${{ github.event.inputs.includePrerelease }} commitAndPush: ${{ github.event.inputs.commitAndPush }}