Skip to content

Commit

Permalink
Use vault to retrieve GitHub token
Browse files Browse the repository at this point in the history
  • Loading branch information
philip-linaro committed Oct 9, 2023
1 parent a9de08d commit 94e1f59
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions exit_automation.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# is set to the email address of the person being exited.

import requests
import shared_vault

CAPABILITIES = [
"CREATE",
Expand All @@ -14,24 +15,20 @@
def create(ticket_data):
""" Ticket has been created """
# Called when the ticket is first created and when the ticket transitions
# to Phase 3. Fire the GitHub Action with the additional information
# required.
fire_github_workflow(ticket_data)


def transition(ticket_data):
""" Check transition state and act accordingly """
# If we've transitioned to Phase 3, fire the GitHub Action accordingly.
# to Phase 3. The latter is handled by the "Exit Leaver - 6 months" SLA.
#
# Fire the GitHub Action with the additional information required.
fire_github_workflow(ticket_data)


def fire_github_workflow(ticket_data):
""" Fire the GitHub Action """
issue_self = ticket_data["self"]
print(f'Triggering workflow for {issue_self}')
bot_authorization = shared_vault.get_secret("secret/github/linaro-build", "pat")
headers = {
'accept': 'application/vnd.github.v3+json',
'authorization': 'token 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'
'authorization': f'token {bot_authorization}'
}
body = {
"ref": "master",
Expand Down

0 comments on commit 94e1f59

Please sign in to comment.