From a412a685499439749eab30cb44c4fc5d3cfe18a4 Mon Sep 17 00:00:00 2001 From: Rajpal Chauhan Date: Wed, 15 Nov 2023 16:05:59 -0800 Subject: [PATCH 01/17] test Signed-off-by: Rajpal Chauhan --- .github/workflows/stale.yaml | 20 ++++++++++++++ .github/workflows/test-delete.yaml | 44 ++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 .github/workflows/stale.yaml create mode 100644 .github/workflows/test-delete.yaml diff --git a/.github/workflows/stale.yaml b/.github/workflows/stale.yaml new file mode 100644 index 000000000..551febf27 --- /dev/null +++ b/.github/workflows/stale.yaml @@ -0,0 +1,20 @@ +name: 'Close stale issues and PRs' +on: + schedule: + - cron: '30 1 * * *' + +jobs: + stale: + runs-on: ubuntu-latest + steps: + - uses: actions/stale@v8 + with: + stale-issue-message: 'This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.' + stale-pr-message: 'This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.' + close-issue-message: 'This issue was closed because it has been stalled for 5 days with no activity.' + close-pr-message: 'This PR was closed because it has been stalled for 10 days with no activity.' + days-before-issue-stale: 30 + days-before-pr-stale: 45 + days-before-issue-close: 5 + days-before-pr-close: 10 + \ No newline at end of file diff --git a/.github/workflows/test-delete.yaml b/.github/workflows/test-delete.yaml new file mode 100644 index 000000000..270fb23f0 --- /dev/null +++ b/.github/workflows/test-delete.yaml @@ -0,0 +1,44 @@ +name: Clean up +on: + pull_request: + types: + - closed + +jobs: + uninstall: + name: Uninstall PR + runs-on: ubuntu-20.04 + if: github.repository_owner == 'bcgov' + steps: + - uses: actions/checkout@v3 + + - name: Authenticate and set context + uses: redhat-actions/oc-login@v1 + with: + openshift_server_url: ${{ secrets.OPENSHIFT_SERVER }} + openshift_token: ${{ secrets.OPENSHIFT_TOKEN }} + certificate_authority_data: ${{ secrets.OPENSHIFT_CA_CRT }} + namespace: ${{ secrets.OPENSHIFT_NAMESPACE }} + + - name: Unistall Traction PR Helm + run: | + helm uninstall pr-${{ github.event.number }}-traction + + - name: Remove Traction Openshift Objects + continue-on-error: true + run: | + oc delete all,secret,pod,networkpolicy,configmap,pvc --selector "app.kubernetes.io/instance"=pr-${{ github.event.number }}-traction + + clean-ghcr: + runs-on: ubuntu-20.04 + name: Delete closed or stale pr images + steps: + - name: Delete containers + uses: snok/container-retention-policy@v2 + with: + image-names: traction-plugins-acapy,traction-tenant-proxy,traction-tenant-ui + cut-off: One hour ago UTC + account-type: org + org-name: ${{ github.repository_owner}} + filter-tags: ${{ github.event.number }} + token: ${{ secrets.PAT }} \ No newline at end of file From c0ba533dd360aeee6209268ce4adc441120e652d Mon Sep 17 00:00:00 2001 From: Rajpal Chauhan Date: Wed, 15 Nov 2023 16:07:21 -0800 Subject: [PATCH 02/17] one month Signed-off-by: Rajpal Chauhan --- .github/workflows/test-delete.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-delete.yaml b/.github/workflows/test-delete.yaml index 270fb23f0..eb35af436 100644 --- a/.github/workflows/test-delete.yaml +++ b/.github/workflows/test-delete.yaml @@ -37,7 +37,7 @@ jobs: uses: snok/container-retention-policy@v2 with: image-names: traction-plugins-acapy,traction-tenant-proxy,traction-tenant-ui - cut-off: One hour ago UTC + cut-off: One month ago UTC account-type: org org-name: ${{ github.repository_owner}} filter-tags: ${{ github.event.number }} From 8e607ebe5aa160ebe77a7ccee5e921772f725e30 Mon Sep 17 00:00:00 2001 From: Rajpal Chauhan Date: Wed, 15 Nov 2023 16:34:53 -0800 Subject: [PATCH 03/17] test Signed-off-by: Rajpal Chauhan --- .github/workflows/test-delete.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test-delete.yaml b/.github/workflows/test-delete.yaml index eb35af436..050fb992e 100644 --- a/.github/workflows/test-delete.yaml +++ b/.github/workflows/test-delete.yaml @@ -1,6 +1,8 @@ name: Clean up on: pull_request: + branches: + - main types: - closed From 8ff5a2f8967a40e43fe956be9219570be5676bb3 Mon Sep 17 00:00:00 2001 From: Rajpal Chauhan Date: Wed, 15 Nov 2023 16:37:35 -0800 Subject: [PATCH 04/17] test Signed-off-by: Rajpal Chauhan --- .github/workflows/test-delete.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test-delete.yaml b/.github/workflows/test-delete.yaml index 050fb992e..bf00d4add 100644 --- a/.github/workflows/test-delete.yaml +++ b/.github/workflows/test-delete.yaml @@ -8,6 +8,7 @@ on: jobs: uninstall: + if: (github.repository == 'bcgov/traction') || (github.event_name == 'workflow_dispatch') name: Uninstall PR runs-on: ubuntu-20.04 if: github.repository_owner == 'bcgov' From cf9d49cb8f3aac0e1e1cadb05be06f525fdac97e Mon Sep 17 00:00:00 2001 From: Rajpal Chauhan Date: Wed, 15 Nov 2023 16:39:00 -0800 Subject: [PATCH 05/17] test Signed-off-by: Rajpal Chauhan --- .github/workflows/test-delete.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test-delete.yaml b/.github/workflows/test-delete.yaml index bf00d4add..16a2a9892 100644 --- a/.github/workflows/test-delete.yaml +++ b/.github/workflows/test-delete.yaml @@ -1,5 +1,6 @@ name: Clean up on: + workflow_dispatch: pull_request: branches: - main From 1c842df783a2ebe5cae479e90ab7be8cc86b6f42 Mon Sep 17 00:00:00 2001 From: Rajpal Chauhan Date: Wed, 15 Nov 2023 16:40:13 -0800 Subject: [PATCH 06/17] test Signed-off-by: Rajpal Chauhan --- .github/workflows/test-delete.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test-delete.yaml b/.github/workflows/test-delete.yaml index 16a2a9892..bf00d4add 100644 --- a/.github/workflows/test-delete.yaml +++ b/.github/workflows/test-delete.yaml @@ -1,6 +1,5 @@ name: Clean up on: - workflow_dispatch: pull_request: branches: - main From dada6ec9005158deb1d27bcde53041c109e7cbe1 Mon Sep 17 00:00:00 2001 From: Rajpal Chauhan Date: Wed, 15 Nov 2023 16:42:30 -0800 Subject: [PATCH 07/17] test Signed-off-by: Rajpal Chauhan --- .github/workflows/test-delete.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test-delete.yaml b/.github/workflows/test-delete.yaml index bf00d4add..877ff574a 100644 --- a/.github/workflows/test-delete.yaml +++ b/.github/workflows/test-delete.yaml @@ -11,7 +11,6 @@ jobs: if: (github.repository == 'bcgov/traction') || (github.event_name == 'workflow_dispatch') name: Uninstall PR runs-on: ubuntu-20.04 - if: github.repository_owner == 'bcgov' steps: - uses: actions/checkout@v3 From d577f0ebb39d8a3808fcf5eb1f9aa0bdf467c50e Mon Sep 17 00:00:00 2001 From: Rajpal Chauhan Date: Wed, 15 Nov 2023 16:51:00 -0800 Subject: [PATCH 08/17] test Signed-off-by: Rajpal Chauhan --- .github/workflows/test-delete.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test-delete.yaml b/.github/workflows/test-delete.yaml index 877ff574a..b47e85720 100644 --- a/.github/workflows/test-delete.yaml +++ b/.github/workflows/test-delete.yaml @@ -5,6 +5,7 @@ on: - main types: - closed + workflow_dispatch: jobs: uninstall: From e3c9c2af45dac753c2fa6d1ce5f581b465e6a396 Mon Sep 17 00:00:00 2001 From: Rajpal Chauhan Date: Thu, 16 Nov 2023 10:38:21 -0800 Subject: [PATCH 09/17] test Signed-off-by: Rajpal Chauhan --- .github/workflows/test-delete.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-delete.yaml b/.github/workflows/test-delete.yaml index b47e85720..025439fef 100644 --- a/.github/workflows/test-delete.yaml +++ b/.github/workflows/test-delete.yaml @@ -23,14 +23,14 @@ jobs: certificate_authority_data: ${{ secrets.OPENSHIFT_CA_CRT }} namespace: ${{ secrets.OPENSHIFT_NAMESPACE }} - - name: Unistall Traction PR Helm + - name: Uninstall Traction PR Helm run: | - helm uninstall pr-${{ github.event.number }}-traction + helm uninstall -n ${{ secrets.OPENSHIFT_NAMESPACE }} pr-${{ github.event.number }}-traction - name: Remove Traction Openshift Objects continue-on-error: true run: | - oc delete all,secret,pod,networkpolicy,configmap,pvc --selector "app.kubernetes.io/instance"=pr-${{ github.event.number }}-traction + oc delete -n ${{ secrets.OPENSHIFT_NAMESPACE }} all,secret,pod,networkpolicy,configmap,pvc --selector "app.kubernetes.io/instance"=pr-${{ github.event.number }}-traction clean-ghcr: runs-on: ubuntu-20.04 From daab0749f796774931756995d612fddf5e9ce886 Mon Sep 17 00:00:00 2001 From: Rajpal Chauhan Date: Thu, 16 Nov 2023 11:09:18 -0800 Subject: [PATCH 10/17] test Signed-off-by: Rajpal Chauhan --- .github/workflows/test-delete.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-delete.yaml b/.github/workflows/test-delete.yaml index 025439fef..b56793843 100644 --- a/.github/workflows/test-delete.yaml +++ b/.github/workflows/test-delete.yaml @@ -25,7 +25,7 @@ jobs: - name: Uninstall Traction PR Helm run: | - helm uninstall -n ${{ secrets.OPENSHIFT_NAMESPACE }} pr-${{ github.event.number }}-traction + helm uninstall -n ${{ secrets.OPENSHIFT_NAMESPACE }} echo pr-${{ github.event.number }}-traction - name: Remove Traction Openshift Objects continue-on-error: true From 0d11b4271bc95a2fccc9b10d2828bdeb8d02886a Mon Sep 17 00:00:00 2001 From: Rajpal Chauhan Date: Thu, 16 Nov 2023 11:13:50 -0800 Subject: [PATCH 11/17] test Signed-off-by: Rajpal Chauhan --- .github/workflows/test-delete.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-delete.yaml b/.github/workflows/test-delete.yaml index b56793843..e05f5fafa 100644 --- a/.github/workflows/test-delete.yaml +++ b/.github/workflows/test-delete.yaml @@ -25,7 +25,9 @@ jobs: - name: Uninstall Traction PR Helm run: | - helm uninstall -n ${{ secrets.OPENSHIFT_NAMESPACE }} echo pr-${{ github.event.number }}-traction + echo "Namespace: ${{ secrets.OPENSHIFT_NAMESPACE }}" + echo "Release Name: pr-${{ github.event.number }}-traction" +# helm uninstall -n ${{ secrets.OPENSHIFT_NAMESPACE }} echo pr-${{ github.event.number }}-traction - name: Remove Traction Openshift Objects continue-on-error: true From 61cde719f7f4921de6330018af8e66b3d4db8acc Mon Sep 17 00:00:00 2001 From: Rajpal Chauhan Date: Thu, 16 Nov 2023 11:17:22 -0800 Subject: [PATCH 12/17] test Signed-off-by: Rajpal Chauhan --- .github/workflows/test-delete.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-delete.yaml b/.github/workflows/test-delete.yaml index e05f5fafa..d7836c24d 100644 --- a/.github/workflows/test-delete.yaml +++ b/.github/workflows/test-delete.yaml @@ -25,8 +25,8 @@ jobs: - name: Uninstall Traction PR Helm run: | - echo "Namespace: ${{ secrets.OPENSHIFT_NAMESPACE }}" - echo "Release Name: pr-${{ github.event.number }}-traction" + echo ${{ secrets.OPENSHIFT_NAMESPACE }} + echo pr-${{ github.event.number }}-traction # helm uninstall -n ${{ secrets.OPENSHIFT_NAMESPACE }} echo pr-${{ github.event.number }}-traction - name: Remove Traction Openshift Objects From c59ae6b68fb4fe5c5553812c1e8bd60a0a0a1da0 Mon Sep 17 00:00:00 2001 From: Rajpal Chauhan Date: Thu, 16 Nov 2023 11:41:45 -0800 Subject: [PATCH 13/17] test Signed-off-by: Rajpal Chauhan --- .github/workflows/test-delete.yaml | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test-delete.yaml b/.github/workflows/test-delete.yaml index d7836c24d..5b5d2fd6e 100644 --- a/.github/workflows/test-delete.yaml +++ b/.github/workflows/test-delete.yaml @@ -34,16 +34,31 @@ jobs: run: | oc delete -n ${{ secrets.OPENSHIFT_NAMESPACE }} all,secret,pod,networkpolicy,configmap,pvc --selector "app.kubernetes.io/instance"=pr-${{ github.event.number }}-traction - clean-ghcr: - runs-on: ubuntu-20.04 - name: Delete closed or stale pr images - steps: + - name: Debug Information + run: | + echo "Bearer Token: ${{ secrets.PAT }}" + echo "GitHub Event Number: ${{ github.event.number }}" + - name: Delete containers uses: snok/container-retention-policy@v2 with: - image-names: traction-plugins-acapy,traction-tenant-proxy,traction-tenant-ui + image-names: traction-plugins-acapy,traction-tenant-proxy,traction-tenant-ui cut-off: One month ago UTC account-type: org org-name: ${{ github.repository_owner}} filter-tags: ${{ github.event.number }} - token: ${{ secrets.PAT }} \ No newline at end of file + token: ${{ secrets.PAT }} + + # clean-ghcr: + # runs-on: ubuntu-20.04 + # name: Delete closed or stale pr images + # steps: + # - name: Delete containers + # uses: snok/container-retention-policy@v2 + # with: + # image-names: traction-plugins-acapy,traction-tenant-proxy,traction-tenant-ui + # cut-off: One month ago UTC + # account-type: org + # org-name: ${{ github.repository_owner}} + # filter-tags: ${{ github.event.number }} + # token: ${{ secrets.PAT }} \ No newline at end of file From dea51aa40cf4c1e4ebdcf722e58c66593db9ab5e Mon Sep 17 00:00:00 2001 From: Rajpal Chauhan Date: Thu, 16 Nov 2023 11:50:38 -0800 Subject: [PATCH 14/17] test Signed-off-by: Rajpal Chauhan --- .github/workflows/test-delete.yaml | 31 ++++++++---------------------- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/.github/workflows/test-delete.yaml b/.github/workflows/test-delete.yaml index 5b5d2fd6e..5a48afad3 100644 --- a/.github/workflows/test-delete.yaml +++ b/.github/workflows/test-delete.yaml @@ -26,39 +26,24 @@ jobs: - name: Uninstall Traction PR Helm run: | echo ${{ secrets.OPENSHIFT_NAMESPACE }} - echo pr-${{ github.event.number }}-traction -# helm uninstall -n ${{ secrets.OPENSHIFT_NAMESPACE }} echo pr-${{ github.event.number }}-traction + echo pr-${{ github.event.number }}-traction" + helm uninstall -n ${{ secrets.OPENSHIFT_NAMESPACE }} echo pr-${{ github.event.number }}-traction - name: Remove Traction Openshift Objects continue-on-error: true run: | oc delete -n ${{ secrets.OPENSHIFT_NAMESPACE }} all,secret,pod,networkpolicy,configmap,pvc --selector "app.kubernetes.io/instance"=pr-${{ github.event.number }}-traction - - name: Debug Information - run: | - echo "Bearer Token: ${{ secrets.PAT }}" - echo "GitHub Event Number: ${{ github.event.number }}" - + clean-ghcr: + runs-on: ubuntu-20.04 + name: Delete closed or stale pr images + steps: - name: Delete containers uses: snok/container-retention-policy@v2 with: - image-names: traction-plugins-acapy,traction-tenant-proxy,traction-tenant-ui + image-names: traction-plugins-acapy,traction-tenant-proxy,traction-tenant-ui cut-off: One month ago UTC account-type: org org-name: ${{ github.repository_owner}} filter-tags: ${{ github.event.number }} - token: ${{ secrets.PAT }} - - # clean-ghcr: - # runs-on: ubuntu-20.04 - # name: Delete closed or stale pr images - # steps: - # - name: Delete containers - # uses: snok/container-retention-policy@v2 - # with: - # image-names: traction-plugins-acapy,traction-tenant-proxy,traction-tenant-ui - # cut-off: One month ago UTC - # account-type: org - # org-name: ${{ github.repository_owner}} - # filter-tags: ${{ github.event.number }} - # token: ${{ secrets.PAT }} \ No newline at end of file + token: ${{ secrets.PAT }} \ No newline at end of file From e29ff94a2fc32fb48204fe49c0a7cc57875ef570 Mon Sep 17 00:00:00 2001 From: Rajpal Chauhan Date: Thu, 16 Nov 2023 11:53:59 -0800 Subject: [PATCH 15/17] test Signed-off-by: Rajpal Chauhan --- .github/workflows/test-delete.yaml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-delete.yaml b/.github/workflows/test-delete.yaml index 5a48afad3..0ac156d87 100644 --- a/.github/workflows/test-delete.yaml +++ b/.github/workflows/test-delete.yaml @@ -24,10 +24,8 @@ jobs: namespace: ${{ secrets.OPENSHIFT_NAMESPACE }} - name: Uninstall Traction PR Helm - run: | - echo ${{ secrets.OPENSHIFT_NAMESPACE }} - echo pr-${{ github.event.number }}-traction" - helm uninstall -n ${{ secrets.OPENSHIFT_NAMESPACE }} echo pr-${{ github.event.number }}-traction + run: | + helm uninstall -n ${{ secrets.OPENSHIFT_NAMESPACE }} pr-${{ github.event.number }}-traction - name: Remove Traction Openshift Objects continue-on-error: true From d6452badcc884c7cb05540a99b28a9bc291ad6ba Mon Sep 17 00:00:00 2001 From: Rajpal Chauhan Date: Thu, 16 Nov 2023 17:15:31 -0800 Subject: [PATCH 16/17] test Signed-off-by: Rajpal Chauhan --- .github/workflows/test-delete.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-delete.yaml b/.github/workflows/test-delete.yaml index 0ac156d87..029d5a349 100644 --- a/.github/workflows/test-delete.yaml +++ b/.github/workflows/test-delete.yaml @@ -25,7 +25,7 @@ jobs: - name: Uninstall Traction PR Helm run: | - helm uninstall -n ${{ secrets.OPENSHIFT_NAMESPACE }} pr-${{ github.event.number }}-traction + helm uninstall -n ${{ secrets.OPENSHIFT_NAMESPACE }} pr-992-traction - name: Remove Traction Openshift Objects continue-on-error: true From c70096ae2de9d103ed2999eda232ed0c59711886 Mon Sep 17 00:00:00 2001 From: Rajpal Chauhan Date: Thu, 16 Nov 2023 22:04:21 -0800 Subject: [PATCH 17/17] adding github.event.number Signed-off-by: Rajpal Chauhan --- .github/workflows/test-delete.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-delete.yaml b/.github/workflows/test-delete.yaml index 029d5a349..ab9f9bbd7 100644 --- a/.github/workflows/test-delete.yaml +++ b/.github/workflows/test-delete.yaml @@ -25,7 +25,7 @@ jobs: - name: Uninstall Traction PR Helm run: | - helm uninstall -n ${{ secrets.OPENSHIFT_NAMESPACE }} pr-992-traction + helm uninstall -n ${{ secrets.OPENSHIFT_NAMESPACE }} pr-${{ github.event.number }}-traction - name: Remove Traction Openshift Objects continue-on-error: true