Skip to content

Commit

Permalink
Added the basic pipeline code
Browse files Browse the repository at this point in the history
  • Loading branch information
sangeet-joy_xero committed Sep 18, 2024
1 parent 7b219fe commit 975d497
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .github/octokit/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import {Octokit} from "@octokit/rest";
import {createAppAuth} from "@octokit/auth-app"

export const getAccessToken = async () => {

const {GITHUB_APP_ID, GITHUB_APP_PRIVATE_KEY} = process.env

const octoKitInstance = new Octokit({
authStrategy: createAppAuth,
auth: {
appId: GITHUB_APP_ID,
privateKey: GITHUB_APP_PRIVATE_KEY
}
});

const {data: installations} = await octoKitInstance.rest.apps.listInstallations()

if(!installations.length) {
throw new Error("No Installations found for this github app")
}

const installationId = installations[0].id;

const installationAccessToken = await octoKitInstance.rest.apps.createInstallationAccessToken({installation_id: installationId})

return installationAccessToken.data.token
}
16 changes: 16 additions & 0 deletions .github/octokit/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "xero-octokit",
"version": "1.0.0",
"description": "",
"main": "index.js",
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"@octokit/auth-app": "^7.1.1",
"@octokit/rest": "^21.0.2"
}
}
41 changes: 41 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Open API PR check

on:
pull_request:
paths:
- '**'

jobs:
pr-health-check:
runs-on: ubuntu-latest

steps:
- name: Checkout codegen repo
uses: actions/checkout@v4
with:
repository: xero-internal/xeroapi-sdk-codegen
path: xeroapi-sdk-codegen

# - name: Install octokit dependencies
# run: npm i
# working-directory: xeroapi-sdk-codegen/.github/octokit

# - name: Get github app access token
# id: get_access_token
# env:
# GITHUB_APP_ID: ${{ secrets.XERO_GITHUB_APP_ID }}
# GITHUB_APP_PRIVATE_KEY: ${{ secrets.XERO_GITHUB_APPLICATION_KEY }}
# uses: actions/github-script@v7
# with:
# result-encoding: string
# script: |
# const { getAccessToken } = await import('${{ github.workspace }}/xeroapi-sdk-codegen/.github/octokit/index.js')
# const token = await getAccessToken()
# return token

# - name: Checkout xero-node repo
# uses: actions/checkout@v4
# with:
# repository: XeroAPI/xero-node
# path: xero-node
# token: ${{steps.get_access_token.outputs.result}}

0 comments on commit 975d497

Please sign in to comment.