Skip to content
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
4f30dd6
[PETOSS-829] added OAS-release actions and PR- Health check
ryanNexus Oct 23, 2025
27ddddf
fix: change npm ci to npm install and add package-lock.json
ryanNexus Oct 23, 2025
a07f371
[PETOSS-829] use npm ci not install as its faster
ryanNexus Oct 23, 2025
4f15215
[PETOSS-829] use latest version of npm
ryanNexus Oct 23, 2025
a950752
[PETOSS-829] gha fixes
ryanNexus Oct 23, 2025
8a7e8c0
[PETOSS-829] gha fixes +1
ryanNexus Oct 23, 2025
d046385
[PETOSS-829] gha fixes +2
ryanNexus Oct 23, 2025
87c005e
[PETOSS-829] gha fixes +3
ryanNexus Oct 23, 2025
3ae3ee1
[PETOSS-829] gha fixes +4
ryanNexus Oct 23, 2025
9492985
fix: use public npm registry instead of Xero Artifactory
ryanNexus Oct 23, 2025
92c753e
[PETOSS-829] removed linter as its now a seperate action
ryanNexus Oct 23, 2025
fd4f976
[PETOSS-829] gha fixes +5
ryanNexus Oct 23, 2025
4d31438
[PETOSS-829] rolledback to v1 of dispatch as v2 creates a distinct i…
ryanNexus Oct 23, 2025
baf70ab
[PETOSS-829] updated how the sdk generation is called
ryanNexus Oct 23, 2025
f9bf5b2
[PETOSS-829] increase timeout
ryanNexus Oct 23, 2025
1d8fa8f
[PETOSS-829] removed disabled linting steps
ryanNexus Oct 23, 2025
0ae6260
[PETOSS-829] re phrased readme
ryanNexus Oct 23, 2025
f3f6795
[PETOSS-829] re named OAS release to Github release
ryanNexus Oct 23, 2025
bc66166
[PETOSS-829] removed auto merge GHA step
ryanNexus Oct 23, 2025
f351437
[PETOSS-829] removed redundant code
ryanNexus Oct 23, 2025
d884869
[PETOSS-829] removed more auto merging code
ryanNexus Oct 23, 2025
cd1d669
[PETOSS-829] renamed package to function name
ryanNexus Oct 23, 2025
5833874
[PETOSS-829] moved commit lint files to .github folder
ryanNexus Oct 23, 2025
499a03e
[PETOSS-829] set working directory for commit lint
ryanNexus Oct 23, 2025
e5e3798
[PETOSS-829] Update package config
the-chris-mitchell Oct 24, 2025
6b0ee15
[PETOSS-829] Remove workflow and generator code
the-chris-mitchell Oct 24, 2025
2948e67
[PETOSS-829] Rename workflows
the-chris-mitchell Oct 24, 2025
309009a
[PETOSS-829] Make consistent and update naming
the-chris-mitchell Oct 24, 2025
2b26a3d
[PETOSS-829] Increase timeout
the-chris-mitchell Oct 24, 2025
3f39109
[PETOSS-829] Change config file format
the-chris-mitchell Oct 27, 2025
619da55
[PETOSS-829] Update installation process and paths
the-chris-mitchell Oct 27, 2025
1eb1bcc
[PETOSS-829] Rename jobs
the-chris-mitchell Oct 27, 2025
500f0b7
[PETOSS-829] Reformat yaml
the-chris-mitchell Oct 27, 2025
0502525
[PETOSS-829] Consolidate pr validation steps
the-chris-mitchell Oct 28, 2025
04e9e89
[PETOSS-829] Update linter version
the-chris-mitchell Oct 28, 2025
71173b0
[PETOSS-829] Add specific job names
the-chris-mitchell Oct 28, 2025
742f826
[PETOSS-829] Use correct option key
the-chris-mitchell Oct 28, 2025
996aeab
[PETOSS-829] Move spectral into megalinter
the-chris-mitchell Oct 28, 2025
8a063d3
[PETOSS-829] Tidy up file no longer required
the-chris-mitchell Oct 28, 2025
f1d9de5
[PETOSS-829] Update megalinter and spectral config
the-chris-mitchell Oct 28, 2025
240ddb8
[PETOSS-829] Rename file
the-chris-mitchell Oct 28, 2025
1ae9e67
[PETOSS-829] Install spectral plugin
the-chris-mitchell Oct 28, 2025
3121e22
[PETOSS-829] Update megalinter config
the-chris-mitchell Oct 28, 2025
6aa3759
[PETOSS-829] Remove actionslint
the-chris-mitchell Oct 28, 2025
438a948
[PETOSS-829] Disable rules
the-chris-mitchell Oct 28, 2025
384192a
Merge branch 'master' of https://github.com/XeroAPI/Xero-OpenAPI into…
the-chris-mitchell Oct 28, 2025
be02f96
[PETOSS-829] Only lint OAS files
the-chris-mitchell Oct 28, 2025
6cc7239
[PETOSS-829] Disable rules
the-chris-mitchell Oct 28, 2025
79492f1
[PETOSS-829] Disable flavor suggestions
the-chris-mitchell Oct 28, 2025
70a0f90
[PETOSS-829] Rename package
the-chris-mitchell Oct 28, 2025
f089547
[PETOSS-829] Add comments and newlines back in
the-chris-mitchell Oct 28, 2025
a56eb31
[PETOSS-829] Remove mention of commitlint
the-chris-mitchell Oct 28, 2025
a4820db
[PETOSS-829] Reword note
the-chris-mitchell Oct 28, 2025
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
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"
},
Comment thread
ryanNexus marked this conversation as resolved.
Outdated
"author": "",
"license": "ISC",
"dependencies": {
"@octokit/auth-app": "^7.1.1",
"@octokit/rest": "^21.0.2"
}
}
9 changes: 9 additions & 0 deletions .github/semantic-release/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "openapi-release",
"private": true,
"devDependencies": {
"@semantic-release/git": "^10.0.1",
"@semantic-release/github": "^11.0.0",
"semantic-release": "^24.1.1"
}
}
20 changes: 20 additions & 0 deletions .github/semantic-release/release.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const config = {
branches: ['master'],
tagFormat: "${version}",
plugins: [
['@semantic-release/release-notes-generator',
{
preset: 'angular',
writerOpts: {
headerPartial: '## What\'s changed',
footerPartial: '\n**Full Changelog**:https://github.com/XeroAPI/Xero-OpenAPI/compare/{{previousTag}}...{{version}}'
}
}
],
'@semantic-release/commit-analyzer',
'@semantic-release/github',
'@semantic-release/git',

]
}
module.exports = config;
35 changes: 35 additions & 0 deletions .github/workflows/github-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Create Github Release

on:
workflow_dispatch:

jobs:
Github-release:
runs-on: ubuntu-latest
permissions:
contents: write
issues: write
pull-requests: write

steps:

- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Node environment
uses: actions/setup-node@v4
with:
node-version: 20

- name: install node package
run: npm i
working-directory: ${{ github.workspace }}/.github/semantic-release

- name: Perform release
run: |
npx semantic-release
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
working-directory: ${{ github.workspace }}/.github/semantic-release
91 changes: 91 additions & 0 deletions .github/workflows/pr-health-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: OAS PR health check

on:
pull_request:
types: [opened, reopened, synchronize]
branches:
- master
push:
branches:
- master

jobs:
pr-health-check:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
actions: read

steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Node environment
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: 'https://registry.npmjs.org'

- name: Install dependencies
timeout-minutes: 5
run: |
npm config set registry https://registry.npmjs.org
npm ci --verbose

- name: Install octokit dependencies
run: npm i
working-directory: ${{ github.workspace }}/.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 }}/.github/octokit/index.js')
const token = await getAccessToken()
return token

- name: Trigger all SDK workflow
id: return_dispatch
env:
GH_TOKEN: ${{ steps.get_access_token.outputs.result }}
run: |
BRANCH_NAME="${{ github.event_name == 'pull_request' && github.head_ref || 'master' }}"

# Trigger the workflow and capture the response
gh workflow run pr.yml \
--repo xero-internal/xeroapi-sdk-codegen \
--ref master \
--field branch_name="$BRANCH_NAME"

# Wait a moment for the run to be created
sleep 5

# Get the latest run ID for the workflow
RUN_ID=$(gh run list \
--repo xero-internal/xeroapi-sdk-codegen \
--workflow=pr.yml \
--limit 1 \
--json databaseId \
--jq '.[0].databaseId')

echo "run_id=$RUN_ID" >> $GITHUB_OUTPUT
echo "Triggered workflow run ID: $RUN_ID"

- name: Checking SDK health status
uses: Codex-/await-remote-run@v1.12.2
with:
token: ${{ steps.get_access_token.outputs.result }}
repo: xeroapi-sdk-codegen
owner: xero-internal
run_id: ${{ steps.return_dispatch.outputs.run_id }}
workflow_time_minimum: 60
max_timeout: 3600

150 changes: 150 additions & 0 deletions .github/workflows/update-OAS-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
name: Update OAS version and raise PR

on:
release:
types: [published]

jobs:
Update-yaml-version:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write

steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
ref: 'master'

- name: Install octokit dependencies
run: npm i
working-directory: ${{ github.workspace }}/.github/octokit

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

- name: Fetch Latest release number
id: get_latest_release_number
run: |
latest_version=$(gh release view --json tagName --jq '.tagName')
echo "Latest release version is - $latest_version"
echo "releaseVersion=$latest_version" >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{steps.get_access_token.outputs.result}}


- name: Set up branch name
id: identify_branch_name
run: |
branch_name='OAS-version-update-${{steps.get_latest_release_number.outputs.releaseVersion}}'
echo "branchName=$branch_name" >> $GITHUB_OUTPUT

- name: Checkout branch
run: |
if git ls-remote --heads origin ${{steps.identify_branch_name.outputs.branchName}} | grep -q "refs/heads/${{steps.identify_branch_name.outputs.branchName}}"; then
echo "checking out existing branch"
git fetch origin > /dev/null 2>&1
git checkout ${{steps.identify_branch_name.outputs.branchName}}
else
echo "branch does not exists, creating new branch"
echo "branchName *****>> ${{steps.identify_branch_name.outputs.branchName}}"
git checkout -b ${{steps.identify_branch_name.outputs.branchName}}
fi

- name: Update OAS version of the spec yaml files
run: |
for file in xero_accounting.yaml xero_assets.yaml xero_bankfeeds.yaml xero_files.yaml xero-app-store.yaml xero-finance.yaml xero-identity.yaml xero-payroll-au.yaml xero-payroll-nz.yaml xero-payroll-uk.yaml xero-projects.yaml; do
yq eval --no-colors --prettyPrint ".info.version = \"${{steps.get_latest_release_number.outputs.releaseVersion}}\"" -i "$file"
echo "updated version in $file"
done

- name: Staging & commiting
id: detect-changes
run: |
CHANGES_DETECTED=$(git diff)
if [ -z "$CHANGES_DETECTED" ]; then
echo "no new changes, nothing to commit"
echo "changes_detected=false" >> $GITHUB_OUTPUT
else
echo "changes_detected=true" >> $GITHUB_OUTPUT
echo "running the git commands......"

git branch

echo "git status 1"
git status

echo 'staging the changes'
git add --all

echo 'git status'
git diff

echo "git config setup"
git config --global user.name "Github Actions"
git config --global user.email "actions@github.com"

echo 'commiting changes....'
git commit -m "chore: version update for all the yaml files"
fi

- name: Pushing the Branch
run: |
if [ "${{steps.detect-changes.outputs.changes_detected}}" == "true" ]; then
echo "pushing the code to ${{steps.identify_branch_name.outputs.branchName}}"
git branch
git push origin ${{steps.identify_branch_name.outputs.branchName}}
else
echo "branch is already up to date"
fi

- name: Create PR
run: |
if [ "${{steps.detect-changes.outputs.changes_detected}}" == "true" ]; then
echo "Creating PR in ${{steps.identify_branch_name.outputs.branchName}}"
gh pr create \
--title "OAS version update - ${{steps.get_latest_release_number.outputs.releaseVersion}}" \
--base master \
--head ${{steps.identify_branch_name.outputs.branchName}} \
--body "chore: version update for all the yaml files"
else
echo "PR is already up to date"
fi
env:
GH_TOKEN: ${{steps.get_access_token.outputs.result}}

- name: Find PR number to merge
id: identify_PR_number
run: |
BRANCH_NAME=${{steps.identify_branch_name.outputs.branchName}}
PR_NUMBER=$(gh pr list --head "$BRANCH_NAME" --json number --jq '. [0].number')
echo "PR number: $PR_NUMBER"
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{steps.get_access_token.outputs.result}}

- name: Verify PR is merged
run: |
pr_state=$(gh pr view ${{steps.identify_PR_number.outputs.PR_NUMBER}} --json state --jq '.state')

echo "pr state: $pr_state"

if [ $pr_state == "MERGED" ]; then
echo "PR ${{steps.identify_PR_number.outputs.PR_NUMBER}} has been merged"
else
echo "PR ${{steps.identify_PR_number.outputs.PR_NUMBER}} is not merged"
exit 1
fi
env:
GH_TOKEN: ${{steps.get_access_token.outputs.result}}
Comment thread
ryanNexus marked this conversation as resolved.
Outdated
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
registry=https://registry.npmjs.org/
Loading
Loading