FIX: fix mixpanel missing import #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Auto assign pull requests | |
on: | |
pull_request: | |
types: | |
- opened | |
jobs: | |
update_pr: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: tibdex/github-app-token@v1.6.0 | |
id: generate-token | |
with: | |
app_id: ${{ secrets.METABASE_BOT_APP_ID }} | |
private_key: ${{ secrets.METABASE_BOT_APP_PRIVATE_KEY }} | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Assign author and their team. Returns true if team exists. | |
id: auto-assign | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{ steps.generate-token.outputs.token }} | |
script: | | |
const fs = require('fs'); | |
const teamConfig = JSON.parse(fs.readFileSync('.github/team.json', 'utf-8')); | |
const prAuthor = context.payload.pull_request.user.login; | |
const prNumber = context.payload.pull_request.number; | |
if (prAuthor.endsWith('[bot]')) { | |
return false; | |
} | |
// Assign PR author | |
await github.rest.issues.addAssignees({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: prNumber, | |
assignees: [prAuthor] | |
}); | |
const team = teamConfig.teams.find(t => t.members.includes(prAuthor)); | |
if (!team) { | |
console.log('You are not assigned to any team. If you need one, update .github/team.json'); | |
return false; | |
} | |
try { | |
const label = await github.rest.issues.getLabel({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
name: team.label | |
}); | |
} catch (e) { | |
console.log(`The label ${team.label} does not exist, create it first`); | |
return false; | |
} | |
// Add team label | |
await github.rest.issues.addLabels({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: prNumber, | |
labels: [team.label] | |
}); | |
return true; | |
- uses: actions/add-to-project@v0.5.0 | |
if: ${{ fromJSON(steps.auto-assign.outputs.result) }} | |
with: | |
project-url: https://github.com/orgs/metabase/projects/50/views/1 | |
github-token: ${{ steps.generate-token.outputs.token }} |