Skip to content

[Facebook]

[Facebook] #249

on:
issues:
types: [opened]
workflow_dispatch:
jobs:
auto_close_issues:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'issues' }}
steps:
- name: 'Close issue and add wontfix label'
uses: actions/github-script@v3
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const issueBody = context.payload.issue.body;
const labels = context.payload.issue.labels.map(label => label.name);
if ((issueBody.includes('instagram') || issueBody.includes('facebook') || issueBody.includes('twitter')) && labels.includes('bug')) {
await github.issues.update({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
state: 'closed'
});
await github.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['wontfix']
});
await github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'Please check issue https://github.com/JunkFood02/Seal/issues/733 for more info.'
});
}
label_and_close_old_issues:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'workflow_dispatch' }}
steps:
- name: 'Label and close old issues'
uses: actions/github-script@v3
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const q = 'instagram in:body label:bug repo:${{ github.repository }} OR facebook in:body label:bug repo:${{ github.repository }} state:open';
github.paginate(github.search.issuesAndPullRequests, { q }, (response) => {
response.data.forEach(async issue => {
const labels = issue.labels.map(label => label.name);
if (!labels.includes('wontfix')) {
await github.issues.addLabels({
issue_number: issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['wontfix']
});
}
await github.issues.update({
issue_number: issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
state: 'closed'
});
await github.issues.createComment({
issue_number: issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'Please check issue https://github.com/JunkFood02/Seal/issues/733 for more info.'
});
})
})