Skip to content

Commit

Permalink
fix: update readme and fix minor bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaagrav committed Dec 24, 2022
1 parent 3899ec9 commit a7c8ee1
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 54 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/package-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ jobs:
run: |
npm i
npm run build
git config --global user.email "[email protected]"
git config --global user.name "Atlan"
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
git config --global user.name "GitHub Actions"
git add .
git commit -am "chore: package action"
git push -u origin main
git commit -m "chore: Update dist" || echo "No changes to commit"
git push origin HEAD:master
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.env
node_modules/
event.json
event.json
.idea
.DS_Store
84 changes: 43 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,58 +1,60 @@
# Atlan dbt action
# Atlan dbt Action

Get comments about downstream assets affected when you make changes to your dbt model SQL files.
### Overview

## Prerequisites
---

- Login to your Atlan Instance.
- [Create Atlan Bearer Token.](https://ask.atlan.com/hc/en-us/articles/8312649180049)
Have you changed a dbt model and realised that it broke a table or a dashboard downstream?

## Usage
To solve that, we’ve created a GitHub action that will add Atlan's lineage context right in your pull request. So before merging the PR, you know the downstream impact of the change

1. Set up your credentials as secrets in your repository settings using `ATLAN_INSTANCE_URL` and `ATLAN_API_TOKEN`.
![Github Action comment screenshot](https://iili.io/HI7d0zB.png)

2. Add the following to your workflow
### Prerequisites

```yml
name: Atlan dbt action
---

on:
pull_request:
types: [opened, edited, synchronize, reopened, closed]
- **Atlan API token**[How to create Atlan api key.](https://ask.atlan.com/hc/en-us/articles/8312649180049)

jobs:
get-downstream-assets:
name: Get Downstream Assets
runs-on: ubuntu-latest
steps:
- name: Run Action
uses: atlanhq/dbt-action@v1
with:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
ATLAN_INSTANCE_URL: ${{secrets.ATLAN_INSTANCE_URL}}
ATLAN_API_TOKEN: ${{secrets.ATLAN_API_TOKEN}}
```
### How to setup

## Inputs
| Name | Description | Required |
| -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
| `GITHUB_TOKEN` | Needed to write comments on PRs to print all the downstream assets. [How Github Tokens work?](https://dev.to/github/the-githubtoken-in-github-actions-how-it-works-change-permissions-customizations-3cgp) | `true` |
| `ATLAN_INSTANCE_URL` | Needed for making API requests to the user's tenant. | `true` |
| `ATLAN_API_TOKEN` | Needed for authenticating API requests to the user's tenant. [Create an Atlan Bearer Token.](https://ask.atlan.com/hc/en-us/articles/8312649180049) | `true` |
---

## Setup
1. Set Atlan Instance URL and API Token as repository secrets in your repository.
1. [How to set GitHub Action secrets in your repository.](https://github.com/Azure/actions-workflow-samples/blob/master/assets/create-secrets-for-GitHub-workflows.md#creating-secrets)

Check out the [documentation](https://github.com/atlanhq/dbt-action/blob/main/SETUP.md) for setting up this action and testing it locally.
![Actions Secrets Screenshot](https://iili.io/HI7gfx2.png)

## Third Party Licenses
2. Add the GitHub Action to your workflow
1. Create a file in the root directory of your repository, `.github/workflows/atlan-action.yml`
2. Add the following code to your workflow file.

This GitHub Action uses a couple of Node.js modules to work.
```yaml
name: Atlan dbt action

on:
pull_request:
types: [opened, edited, synchronize, reopened, closed]

jobs:
get-downstream-impact:
name: Get Downstream Assets
runs-on: ubuntu-latest
steps:
- name: Run Action
uses: atlanhq/dbt-action@v1
with:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
ATLAN_INSTANCE_URL: ${{secrets.ATLAN_INSTANCE_URL}}
ATLAN_API_TOKEN: ${{secrets.ATLAN_API_TOKEN}}

```

License and other copyright information for each module are included in the release branch of each action version under `node_modules/{module}`.

More information for each package can be found at `https://www.npmjs.com/package/{package}`

## License
## Inputs

[![MIT license](https://img.shields.io/badge/License-MIT-blue.svg)](https://lbesson.mit-license.org/)
| Name | Description | Required |
| --- | --- | --- |
| GITHUB_TOKEN | Needed to write comments on PRs to print all the downstream assets. https://dev.to/github/the-githubtoken-in-github-actions-how-it-works-change-permissions-customizations-3cgp | true |
| ATLAN_INSTANCE_URL | Needed for making API requests to the user's tenant. | true |
| ATLAN_API_TOKEN | Needed for authenticating API requests to the user's tenant. https://ask.atlan.com/hc/en-us/articles/8312649180049 | true |
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: "Atlan dbt Action"
description: "Get all the downstream assets that get affected when dbt model sql files are changed on pull request conversations."
description: "Whenever you make a change to a dbt model, Atlan will add downstream lienage impact context right in your pull requests."
author: "Atlan"

inputs:
Expand Down
13 changes: 10 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17738,13 +17738,16 @@ async function sendSegmentEvent(action, properties) {
"content-type": "application/json",
};

var domain = new URL(segment_ATLAN_INSTANCE_URL).hostname;

var raw = JSON.stringify({
category: "integrations",
object: "github",
action,
properties: {
...properties,
github_action_id: `https://github.com/${github.context.payload.repository.full_name}/actions/runs/${github.context.runId}`,
domain,
},
});

Expand All @@ -17754,12 +17757,16 @@ async function sendSegmentEvent(action, properties) {
body: raw,
};

console.log("send segment event", action, properties);

var response = await fetch(
`${segment_ATLAN_INSTANCE_URL}/api/service/segment/track`,
requestOptions
);
)
.then(() => {
console.log("send segment event", action, raw);
})
.catch((err) => {
console.log("couldn't send segment event", err);
});

return response;
}
Expand Down
13 changes: 10 additions & 3 deletions src/api/segment.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@ export default async function sendSegmentEvent(action, properties) {
"content-type": "application/json",
};

var domain = new URL(ATLAN_INSTANCE_URL).hostname;

var raw = JSON.stringify({
category: "integrations",
object: "github",
action,
properties: {
...properties,
github_action_id: `https://github.com/${context.payload.repository.full_name}/actions/runs/${context.runId}`,
domain,
},
});

Expand All @@ -32,12 +35,16 @@ export default async function sendSegmentEvent(action, properties) {
body: raw,
};

console.log("send segment event", action, properties);

var response = await fetch(
`${ATLAN_INSTANCE_URL}/api/service/segment/track`,
requestOptions
);
)
.then(() => {
console.log("send segment event", action, raw);
})
.catch((err) => {
console.log("couldn't send segment event", err);
});

return response;
}

0 comments on commit a7c8ee1

Please sign in to comment.