Skip to content

Commit

Permalink
adding stale workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
adishM98 committed Oct 16, 2023
1 parent 95b6871 commit 0bb19d5
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 17 deletions.
34 changes: 17 additions & 17 deletions .github/workflows/docs-pr-app.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Render review deploy
name: Render PR deploy
on:
pull_request_target:
types: [labeled, unlabeled, closed]
Expand All @@ -11,8 +11,8 @@ permissions:
issues: write

jobs:
create-review-app:
if: ${{ github.event.action == 'labeled' && github.event.label.name == 'create-review-app' }}
create-review-pr-app:
if: ${{ github.event.action == 'labeled' && github.event.label.name == 'create-review-pr-app' }}
runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -83,7 +83,7 @@ jobs:
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
name: 'create-review-app'
name: 'create-review-pr-app'
})
} catch (e) {
console.log(e)
Expand All @@ -93,11 +93,11 @@ jobs:
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['active-review-app']
labels: ['active-review-pr-app']
})
destroy-review-app:
if: ${{ (github.event.action == 'labeled' && github.event.label.name == 'destroy-review-app') || github.event.action == 'closed' }}
destroy-review-pr-app:
if: ${{ (github.event.action == 'labeled' && github.event.label.name == 'destroy-review-pr-app') || github.event.action == 'closed' }}
runs-on: ubuntu-latest

steps:
Expand All @@ -122,7 +122,7 @@ jobs:
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
name: 'destroy-review-app'
name: 'destroy-review-pr-app'
})
} catch (e) {
console.log(e)
Expand All @@ -133,7 +133,7 @@ jobs:
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
name: 'suspend-review-app'
name: 'suspend-review-pr-app'
})
} catch (e) {
console.log(e)
Expand All @@ -144,7 +144,7 @@ jobs:
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
name: 'active-review-app'
name: 'active-review-pr-app'
})
} catch (e) {
console.log(e)
Expand All @@ -167,8 +167,8 @@ jobs:
run: |
PGPASSWORD=${{ secrets.RENDER_DS_PG_PASS }} psql -h $PGHOST -p $PGPORT -U $PGUSER -d postgres -c "drop database \"$PGDATABASE\" ;"
suspend-review-app:
if: ${{ github.event.action == 'labeled' && github.event.label.name == 'suspend-review-app' }}
suspend-review-pr-app:
if: ${{ github.event.action == 'labeled' && github.event.label.name == 'suspend-review-pr-app' }}
runs-on: ubuntu-latest

steps:
Expand All @@ -193,14 +193,14 @@ jobs:
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
name: 'active-review-app'
name: 'active-review-pr-app'
})
} catch (e) {
console.log(e)
}
resume-review-app:
if: ${{ github.event.action == 'unlabeled' && github.event.label.name == 'suspend-review-app' }}
resume-review-pr-app:
if: ${{ github.event.action == 'unlabeled' && github.event.label.name == 'suspend-review-pr-app' }}
runs-on: ubuntu-latest

steps:
Expand All @@ -224,15 +224,15 @@ jobs:
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['active-review-app']
labels: ['active-review-pr-app']
})
try {
await github.rest.issues.removeLabel({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
name: 'suspend-review-app'
name: 'suspend-review-pr-app'
})
} catch (e) {
console.log(e)
Expand Down
45 changes: 45 additions & 0 deletions .github/workflows/stale-PR-render-deploys.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Label for stale PR render deploys
on:
workflow_dispatch:
schedule:
- cron: "0 0 * * *"

permissions:
issues: write

jobs:
label-stale-deploys:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- uses: akshaysasidrn/stale-label-fetch@v1.1
id: stale-label
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
stale-label: "active-review-pr-app"
stale-time: "86400"
type: "pull_request"
- name: Get stale numbers
run: echo "Matched PR numbers - ${{ steps.stale-label.outputs.stale-numbers }}"
- name: Add suspend label
uses: actions/github-script@v6
env:
STALE_NUMBERS: ${{ steps.stale-label.outputs.stale-numbers }}
with:
github-token: ${{ secrets.TJ_BOT_PAT }}
script: |
if (!process.env.STALE_NUMBERS) return
const prNumbers = process.env.STALE_NUMBERS.split(",")
console.log(`Adding suspend labels for: ${prNumbers}`)
for (const prNumber of prNumbers) {
github.rest.issues.addLabels({
issue_number: prNumber,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['suspend-review-pr-app']
})
}

0 comments on commit 0bb19d5

Please sign in to comment.