> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cortex.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Automate user access to GitHub, PagerDuty, and Jira

export const RecipeBadges = ({badges = []}) => {
  const map = {
    "recipe": {
      label: "Recipe",
      color: "#A86400"
    },
    "ai-excellence": {
      label: "AI excellence",
      color: "#653EE8"
    },
    "production-readiness": {
      label: "Production readiness",
      color: "#226686"
    },
    "incident-mgmt": {
      label: "Incident management",
      color: "#86198F"
    },
    "migrations": {
      label: "Migrations",
      color: "#0E7C66"
    },
    "compliance": {
      label: "Compliance",
      color: "#475569"
    },
    "dora": {
      label: "DORA metrics",
      color: "#1D4ED8"
    },
    "security": {
      label: "Security",
      color: "#B42318"
    },
    "operational-readiness": {
      label: "Operational readiness",
      color: "#B54708"
    },
    "dev-onboarding": {
      label: "Developer onboarding",
      color: "#C11574"
    }
  };
  const items = badges.map(key => map[key]).filter(Boolean);
  if (items.length === 0) return null;
  return <div className="not-prose flex flex-wrap gap-2 mb-6">
      {items.map(b => <span key={b.label} className="rounded-lg px-2 py-1 text-xs font-medium" style={{
    backgroundColor: b.color,
    color: b.textColor || "#FFFFFF"
  }}>
          {b.label}
        </span>)}
    </div>;
};

<RecipeBadges badges={["recipe", "dev-onboarding"]} />

This Workflow automatically sets up new developers with access to GitHub, PagerDuty, and Jira.

#### Step 1: Start creating the Workflow <a href="#step-1-start-creating-the-workflow" id="step-1-start-creating-the-workflow" />

Follow the steps in the documentation to [create a Workflow](/streamline/workflows/create) and [configure its basic settings](/streamline/workflows/create#creating-a-workflow).

#### Step 2: Add blocks to the Workflow <a href="#step-2-add-blocks-to-the-workflow" id="step-2-add-blocks-to-the-workflow" />

The instructions on this page describe how to create this Workflow in the Cortex UI, but it is also possible to copy the Workflow YAML and add it to your workspace via the [Cortex CLI](https://pypi.org/project/cortexapps-cli/). This allows you to quickly set up the example configuration then iterate on it for your own use case. Expand the tile below to learn more.

<Accordion title="Workflow YAML instructions">
  To upload the Workflow example YAML into your workspace:

  1. Save the Workflow example YAML file below:

  ```yaml theme={null}
  name: "Dev Onboarding: User Access"
  tag: dev-onboarding-user-access
  description: "Automatically sets up new developers with access to GitHub, PagerDuty,\
    \ and Jira."
  isDraft: false
  filter:
    type: GLOBAL
  runResponseTemplate: null
  failedRunResponseTemplate: null
  restrictActionCompletionToRunnerUser: false
  actions:
  - name: Get GH Username
    slug: get-gh-username
    schema:
      inputs:
      - name: GitHub Username
        description: Enter your personal GitHub username.
        key: github-username
        required: false
        defaultValue: null
        placeholder: null
        validationRegex: "^[^\\s]+$"
        type: INPUT_FIELD
      inputOverrides: []
      type: USER_INPUT
    outgoingActions:
    - add-user-to-org
    isRootAction: true
  - name: Add user to GH org
    slug: add-user-to-org
    schema:
      inputs:
        org: cortexapps
        role: member
        username: actions.get-gh-username.outputs.github-username
      integrationAlias: cortex
      actionIdentifier: github.addUserToOrg
      type: ADVANCED_HTTP_REQUEST
    outgoingActions:
    - add-user-to-pd
    isRootAction: false
  - name: Add user to PagerDuty
    slug: add-user-to-pd
    schema:
      headers:
        Accept: application/vnd.pagerduty+json;version=2
        Authorization: "Bearer {{context.secrets.pd_token}}"
      httpMethod: POST
      payload: |-
        {
          "user": {
            "type": "user",
            "name": "{{context.initiatedBy.name}}",
            "email": "{{context.initiatedBy.email}}"
          }
        }
      url: https://api.pagerduty.com/users
      type: HTTP_REQUEST
    outgoingActions:
    - add-user-to-jira
    isRootAction: false
  - name: Add user to Jira
    slug: add-user-to-jira
    schema:
      headers: {}
      httpMethod: POST
      payload: |-
        {
          "emailAddress": "{{context.initiatedBy.email}}",
          "displayName": "{{context.initiatedBy.name}}"
        }`
      url: https://cortex.atlassian.net/rest/api/3/user
      type: HTTP_REQUEST
    outgoingActions:
    - send-message
    isRootAction: false
  - name: Send message
    slug: send-message
    schema:
      channel: social
      message: "{{context.initiatedBy.name}} has been added to GitHub, PagerDuty, and\
        \ Jira."
      type: SLACK
    outgoingActions: []
    isRootAction: false
  runRestrictionPolicies: []
  iconTag: AndroidLogo
  variables: []

  ```

  2. Use the [Cortex CLI](https://pypi.org/project/cortexapps-cli/) to run this command, using the path to your Workflow YAML file:<br />
     `cortex workflows create -f <path-to-your-workflow.yaml>`
</Accordion>

Expand the tiles below to learn about each block in this Workflow and how to configure them in the Cortex UI:

<AccordionGroup>
  <Accordion title="User input">
    In this example, we add a User Input block to obtain the user's GitHub username.

    1. Click **+** in the center of the page. In the block library modal, choose **User input**.
    2. In the block configuration side panel, enter a name and unique slug for this block.
       1. In this example, we use the name `Get GH Username` and the slug `get-gh-username`.
    3. Click **+Add user input**. Add the following:
       * **Name**: GitHub Username
       * **Key**: github-username
       * **Description**: Enter your personal GitHub username.
       * **Type**: Text
       * Click **Add input**.
    4. At the bottom of the side panel, click **Save**.
  </Accordion>

  <Accordion title="Add user to GitHub org">
    This block adds a user to a GitHub organization.

    1. Click **+** in the center of the page. In the block library modal, select the **GitHub > Add user to org** block.
    2. In the side panel, enter a name and unique slug for the block.
       * In this example, we use the name `Add user to GH org` and the slug `add-user-to-org`.
    3. Configure the block:
       * **Alias**: Choose which GitHub configuration to use.
       * **Organization**: Enter your GitHub organization name.
       * **Username**: Enter the handle for the user's GitHub account.
         * In our example, we use templating to take the output of the previous step and set it as the value for this field: `actions.get-gh-username.outputs.github-username`
       * **Role**: Select the role of the user in the organization.
    4. At the bottom of the side panel, click **Save**.
  </Accordion>

  <Accordion title="HTTP requests">
    There are two HTTP requests that perform the following actions: Adding the user to PagerDuty and adding the user to Jira.

    **Add the user to PagerDuty**

    1. Click **+** in the center of the page. In the block library modal, select the **HTTP request** block.
    2. In the side panel, enter a name and unique slug for the block.
       * In this example, we use the name `Add user to PagerDuty` and the slug `add-user-to-pd`.
    3. Configure the block:
       1. **HTTP method**: POST
       2. **URL**: In our example, we set this to `https://api.pagerduty.com/users`.
       3. **Headers**: Set the following headers:
          * `Accept`: `application/vnd.pagerduty+json;version=2`
          * `Authorization`: `Bearer {{ context.secrets.pd_token }}`
       4. **Payload**: In our example, we enter the following:

    ```json theme={null}
    {
      "user": {
        "type": "user",
        "name": "{{context.initiatedBy.name}}",
        "email": "{{context.initiatedBy.email}}"
      }
    }
    ```

    4. Save the block.

    **Add the user to Jira**

    1. Click **+** in the center of the page. In the block library modal, select the **HTTP request** block.
    2. In the side panel, enter a name and unique slug for the block.
       * In this example we use the name `Add user to Jira` and the slug `add-user-to-jira`.
    3. Configure the block:
       1. **HTTP method**: POST
       2. **URL**: In our example, we set this to:<br />
          `https://cortex.atlassian.net/rest/api/3/user`
       3. **Payload**: In our example, we enter the following:

    ```json theme={null}
    {
      "emailAddress": "{{context.initiatedBy.email}}",
      "displayName": "{{context.initiatedBy.name}}"
    }`
    ```

    4. Save the block.
  </Accordion>

  <Accordion title="Slack message">
    In this step, we send a templated message via Slack informing the user that they have been added to GitHub, PageryDuty, and Jira.

    1. Click **+** in the center of the page. In the block library modal, select the **Slack** block.
    2. In the side panel, enter a name and unique slug for the block.
       * In this example we use the name `Send message` and the slug `send-message`.
    3. Select a Slack channel name.
    4. Enter text for the message that will be sent via Slack. In our example, we use the following:

    ```
    {{context.initiatedBy.name}} has been added to GitHub, PagerDuty, and Jira.
    ```

    5. Save the block.
  </Accordion>
</AccordionGroup>

#### Step 3: Run the Workflow <a href="#step-3-run-the-workflow" id="step-3-run-the-workflow" />

When you run the Workflow, the following events happen:

* The Workflow pauses to collect a response from the user during the User Input block.
* The "Add user to org" block runs. It uses the output of the previous block as the username, then automatically adds to that user to the specified GitHub org.
* The first HTTP request runs. Using the name and email address of the user who initiated the Workflow, it creates a user in PagerDuty.
* The second HTTP request runs. Using the name and email address of the user who initiated the Workflow, it creates a user in Jira.
* The Slack block runs, which sends a Slack message to the user to let them know that their GitHub, PagerDuty, and Jira accounts are ready.


## Related topics

- [Workflows](/guides/product-areas/workflows.md)
- [PagerDuty](/ingesting-data-into-cortex/integrations/pagerduty.md)
- [Automate user access to Copilot](/guides/dev-onboarding/automate-user-access-to-copilot.md)
