|
| 1 | +name: Create JIRA ticket for dependabot prs |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: [opened] |
| 6 | + |
| 7 | +permissions: |
| 8 | + pull-requests: write |
| 9 | + contents: write |
| 10 | + repository-projects: read |
| 11 | +jobs: |
| 12 | + jira_task: |
| 13 | + name: Create Jira issue |
| 14 | + runs-on: ubuntu-latest |
| 15 | + if: github.actor == 'dependabot[bot]' |
| 16 | + steps: |
| 17 | + - uses: GitHubSecurityLab/actions-permissions/monitor@v1 |
| 18 | + with: |
| 19 | + config: ${{ vars.PERMISSIONS_CONFIG }} |
| 20 | + - name: Checkout code |
| 21 | + |
| 22 | + with: |
| 23 | + fetch-depth: 2 |
| 24 | + - name: set Apix Bot token |
| 25 | + id: app-token |
| 26 | + uses: mongodb/apix-action/token@3024080388613583e3bd119bfb1ab4b4dbf43c42 |
| 27 | + with: |
| 28 | + app-id: ${{ secrets.APIXBOT_APP_ID }} |
| 29 | + private-key: ${{ secrets.APIXBOT_APP_PEM }} |
| 30 | + - name: Find JIRA team |
| 31 | + id: find |
| 32 | + run: | |
| 33 | + # shellcheck disable=SC2016 # intended use of single quotes |
| 34 | + GH_TEAM="$(git diff HEAD~1..HEAD -- go.mod | grep -v '// indirect' | grep -i '^\-' | grep -v '^\-\-\-' | awk '{print $2}' | xargs -I $$ jq -r --arg i $$ '.[$i]' build/ci/library_owners.json | head -1)" |
| 35 | + if [[ ("$GH_TEAM" == "") || ("$GH_TEAM" == "null") ]]; then |
| 36 | + GH_TEAM="apix-2" |
| 37 | + fi |
| 38 | + echo "GH_TEAM=$GH_TEAM" |
| 39 | + JIRA_TEAM="$(jq -r --arg i "$GH_TEAM" '.[$i]' < build/ci/library_owners_jira.json)" |
| 40 | + echo "JIRA_TEAM=$JIRA_TEAM" |
| 41 | + echo "assigned_team=$JIRA_TEAM" >> "${GITHUB_OUTPUT}" |
| 42 | + - name: Create JIRA ticket |
| 43 | + uses: mongodb/apix-action/create-jira@v8 |
| 44 | + id: create |
| 45 | + with: |
| 46 | + token: ${{ secrets.JIRA_API_TOKEN }} |
| 47 | + project-key: CLOUDP |
| 48 | + summary: AtlasCLI Dependency Update n. ${{ github.event.pull_request.number }} |
| 49 | + issuetype: Story |
| 50 | + description: "This ticket tracks the following GitHub pull request: ${{ github.event.pull_request.html_url }}." |
| 51 | + components: AtlasCLI |
| 52 | + assignee: ${{ secrets.ASSIGNEE_JIRA_TICKET }} |
| 53 | + extra-data: | |
| 54 | + { |
| 55 | + "fields": { |
| 56 | + "fixVersions": [ |
| 57 | + { |
| 58 | + "id": "41805" |
| 59 | + } |
| 60 | + ], |
| 61 | + "customfield_12751": [ |
| 62 | + { |
| 63 | + "id": "${{ steps.find.outputs.assigned_team }}" |
| 64 | + } |
| 65 | + ], |
| 66 | + "customfield_10257": { |
| 67 | + "id": "11861" |
| 68 | + } |
| 69 | + } |
| 70 | + } |
| 71 | + - name: Add comment |
| 72 | + uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 |
| 73 | + with: |
| 74 | + issue-number: ${{ github.event.pull_request.number }} |
| 75 | + body: | |
| 76 | + The ticket [${{ steps.create.outputs.issue-key }}](https://jira.mongodb.org/browse/${{ steps.create.outputs.issue-key }}) was created for internal tracking. |
| 77 | +
|
| 78 | + Note: Jira ticket will be closed automatically when this PR is merged. |
| 79 | + - name: Add auto_close_jira label |
| 80 | + env: |
| 81 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 82 | + run: | |
| 83 | + gh pr edit "${{github.event.pull_request.html_url}}" --add-label "auto_close_jira" |
| 84 | + - name: Set auto merge |
| 85 | + env: |
| 86 | + GH_TOKEN: ${{ steps.app-token.outputs.token }} |
| 87 | + run: | |
| 88 | + gh pr merge "${{ github.event.pull_request.html_url }}" --auto --squash |
0 commit comments