Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

github-actions: use GH app to manage the projects #3829

Merged
merged 2 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions .github/workflows/addToProject.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
issues:
types:
- opened, milestoned

permissions:
contents: read

Expand All @@ -11,9 +12,21 @@ jobs:
if: github.event.issue && github.event.issue.milestone
runs-on: ubuntu-latest
steps:
- name: Get token
id: get_token
uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2.1.0
with:
app_id: ${{ secrets.OBS_AUTOMATION_APP_ID }}
private_key: ${{ secrets.OBS_AUTOMATION_APP_PEM }}
permissions: >-
{
"organization_projects": "write",
"issues": "read"
}

- name: Get project data
env:
GITHUB_TOKEN: ${{ secrets.APM_TECH_USER_TOKEN }}
GITHUB_TOKEN: ${{ steps.get_token.outputs.token }}
TEAM: Java
ORGANIZATION: elastic
PROJECT_NUMBER: 595
Expand Down Expand Up @@ -49,7 +62,7 @@ jobs:

- name: Add issue to project
env:
GITHUB_TOKEN: ${{ secrets.APM_TECH_USER_TOKEN }}
GITHUB_TOKEN: ${{ steps.get_token.outputs.token }}
ISSUE_ID: ${{ github.event.issue.node_id }}
run: |
item_id="$( gh api graphql -f query='
Expand All @@ -65,7 +78,7 @@ jobs:

- name: Set fields
env:
GITHUB_TOKEN: ${{ secrets.APM_TECH_USER_TOKEN }}
GITHUB_TOKEN: ${{ steps.get_token.outputs.token }}
run: |
gh api graphql -f query='
mutation (
Expand Down
19 changes: 17 additions & 2 deletions .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,27 @@ jobs:
repo: context.repo.repo,
labels: ["agent-java"]
})

- name: Get token
id: get_token
uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2.1.0
with:
app_id: ${{ secrets.OBS_AUTOMATION_APP_ID }}
private_key: ${{ secrets.OBS_AUTOMATION_APP_PEM }}
permissions: >-
{
"members": "read",
"organization_projects": "write",
"issues": "read"
}

- id: is_elastic_member
uses: elastic/oblt-actions/github/is-member-of@v1
with:
github-org: "elastic"
github-user: ${{ github.actor }}
github-token: ${{ secrets.APM_TECH_USER_TOKEN }}
github-token: ${{ steps.get_token.outputs.token }}

- name: Add community and triage lables
if: contains(steps.is_elastic_member.outputs.result, 'false') && github.actor != 'dependabot[bot]' && github.actor != 'elastic-renovate-prod[bot]'
uses: actions/github-script@v7
Expand All @@ -56,7 +71,7 @@ jobs:
uses: elastic/[email protected]
if: contains(steps.is_elastic_member.outputs.result, 'true') && github.event.pull_request
env:
MY_GITHUB_TOKEN: ${{ secrets.APM_TECH_USER_TOKEN }}
MY_GITHUB_TOKEN: ${{ steps.get_token.outputs.token }}
with:
project: 'https://github.com/orgs/elastic/projects/454'
project_id: '5882982'
Expand Down
Loading