From 7115cf79be8dca989a1c0b94e644586a3be1be06 Mon Sep 17 00:00:00 2001 From: umarcor Date: Tue, 30 Nov 2021 00:27:30 +0100 Subject: [PATCH] add reusable workflow 'ArtifactCleanUp' --- .github/workflows/ArtifactCleanUp.yml | 34 +++++++++++++++++++++++++++ ExamplePipeline.yml | 29 +++++++---------------- 2 files changed, 42 insertions(+), 21 deletions(-) create mode 100644 .github/workflows/ArtifactCleanUp.yml diff --git a/.github/workflows/ArtifactCleanUp.yml b/.github/workflows/ArtifactCleanUp.yml new file mode 100644 index 0000000..ed77abf --- /dev/null +++ b/.github/workflows/ArtifactCleanUp.yml @@ -0,0 +1,34 @@ +name: ArtifactCleanUp + +on: + workflow_call: + inputs: + package: + description: 'Artifacts to be removed on not tagged runs.' + required: true + type: string + remaining: + description: 'Artifacts to be removed unconditionally.' + required: false + default: '' + type: string + +jobs: + + ArtifactCleanUp: + name: 🗑️ Artifact Cleanup + runs-on: ubuntu-latest + + steps: + + - name: 🗑️ Delete package Artifacts + if: ${{ ! startsWith(github.ref, 'refs/tags') }} + uses: geekyeggo/delete-artifact@v1 + with: + name: ${{ inputs.package }} + + - name: 🗑️ Delete remaining Artifacts + if: ${{ inputs.remaining != '' }} + uses: geekyeggo/delete-artifact@v1 + with: + name: ${{ inputs.remaining }} diff --git a/ExamplePipeline.yml b/ExamplePipeline.yml index 9d7a655..b0b14fa 100644 --- a/ExamplePipeline.yml +++ b/ExamplePipeline.yml @@ -111,31 +111,18 @@ jobs: coverage: ${{ fromJson(needs.Params.outputs.params).artifacts.coverage }} typing: ${{ fromJson(needs.Params.outputs.params).artifacts.typing }} - ArtifactCleanUp: - name: 🗑️ Artifact Cleanup - runs-on: ubuntu-latest + uses: pyTooling/Actions/.github/workflows/ArtifactCleanUp.yml@main needs: - Params - Coverage - StaticTypeCheck - BuildTheDocs - PublishToGitHubPages - - steps: - - - name: 🗑️ Delete package Artifacts - if: ${{ ! startsWith(github.ref, 'refs/tags') }} - uses: geekyeggo/delete-artifact@v1 - with: - name: | - ${{ fromJson(needs.Params.outputs.params).artifacts.package }} - - - name: 🗑️ Delete remaining Artifacts - uses: geekyeggo/delete-artifact@v1 - with: - name: | - ${{ fromJson(needs.Params.outputs.params).artifacts.unittesting }}-* - ${{ fromJson(needs.Params.outputs.params).artifacts.coverage }} - ${{ fromJson(needs.Params.outputs.params).artifacts.typing }} - ${{ fromJson(needs.Params.outputs.params).artifacts.doc }} + with: + package: ${{ fromJson(needs.Params.outputs.params).artifacts.package }} + remaining: | + ${{ fromJson(needs.Params.outputs.params).artifacts.unittesting }}-* + ${{ fromJson(needs.Params.outputs.params).artifacts.coverage }} + ${{ fromJson(needs.Params.outputs.params).artifacts.typing }} + ${{ fromJson(needs.Params.outputs.params).artifacts.doc }}