Skip to content
name: Notify about pending release pull requests
on:
# TODO: delete "push" before merge
push:
branches:
- FX-NULL-add-version-packages-pull-request-reminder
schedule:
- cron: '0 9-18/3 * * 1-5' # Runs every 3 hours during from Monday to Friday and only during work hours (e.g., 9 AM to 6 PM)
workflow_dispatch:
jobs:
check-pending-release-pull-requests:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
actions: write
issues: write
pull-requests: write
steps:
- name: Check out the repository
uses: actions/checkout@v3
- name: GSM Secrets
id: secrets_manager
uses: toptal/davinci-github-actions/[email protected]
with:
workload_identity_provider: ${{ secrets.IDENTITY_POOL }}
service_account: ${{ secrets.SA_IDENTITY_POOL }}
secrets_name: |-
NPM_TOKEN_PUBLISH:toptal-ci/NPM_TOKEN_PUBLISH
SLACK_BOT_TOKEN:toptal-ci/SLACK_BOT_TOKEN
TOPTAL_DEVBOT_TOKEN:toptal-ci/TOPTAL_DEVBOT_TOKEN
- name: Parse secrets
id: parse_secrets
uses: toptal/davinci-github-actions/[email protected]
with:
json: ${{ steps.secrets_manager.outputs.secrets }}
- name: Set ENV Variables
shell: bash
run: |-
echo "SLACK_BOT_TOKEN=${{ steps.parse_secrets.outputs.SLACK_BOT_TOKEN }}" >> $GITHUB_ENV
echo "GITHUB_TOKEN=${{ steps.parse_secrets.outputs.TOPTAL_DEVBOT_TOKEN }}" >> $GITHUB_ENV
- name: Find version packages pull requests
uses: actions/github-script@v7
id: find-pull-requests
with:
github-token: ${{ env.GITHUB_TOKEN }}
script: |
const { data: prs } = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
})
// TODO: revert before merge
//const fourHoursInMilliseconds = 4 * 60 * 60 * 1000
const fourHoursInMilliseconds = 0
// Find a PR with the title "Version Packages" that has been open for more than 4 hours
const now = new Date()
const targetPR = prs.find(pr => pr.title.includes('Version Packages') && (now - new Date(pr.created_at)) > fourHoursInMilliseconds)
if (targetPR) {
// If there is at least one pull request, set
core.setOutput('notification_is_needed', 'true')
}
- name: Send a Slack notification if an old "Version Packages" PR is found
if: ${{ steps.find-pull-requests.outputs.notification_is_needed == 'true' }}
uses: slackapi/[email protected]
env:
SLACK_BOT_TOKEN: ${{ env.SLACK_BOT_TOKEN }}
with:
channel-id: "-frontend-exp-team-notifications"
# TODO: add ":x: <!here>" before merge
slack-message: "There is stale Version Packages pull request in <https://github.com/toptal/picasso/pulls|broken>, review and merge it."