Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
77c0af8
Removed Quotes in Examples for accounting.yml
Sep 12, 2024
8cc877c
Corrected examples
Sep 20, 2024
2e0acfe
fixed review comments
Sep 24, 2024
4f14ed7
Merge pull request #628 from XeroAPI/consume-prism-server
vigneshk-tw Sep 24, 2024
f8d07cb
Revert "Merge pull request #628 from XeroAPI/consume-prism-server"
Sep 24, 2024
d149fbb
Merge pull request #631 from XeroAPI/revert-#628-prism-changes
vigneshk-tw Sep 24, 2024
aeed4b3
corrected the examples except accounting.yml
Sep 24, 2024
09d412c
removed quotes only from example in accounting.yml
Sep 24, 2024
94567c8
corrected date format in accounting.yml
Sep 24, 2024
d67c075
adds missing invoice address field
Sep 24, 2024
539d289
adds example w.r to dotnet test cases
Sep 25, 2024
ac61390
converted format from binary to byte --> TESTING
Sep 25, 2024
9797655
removed example added
Sep 25, 2024
757ff78
removed newly added examples
Sep 25, 2024
0796dfa
adds example for CISOrgSettings
Sep 25, 2024
02dddb3
corrected the example structure
Sep 25, 2024
7aab3c7
corrected failed test case
Sep 25, 2024
e217de6
Merge pull request #634 from XeroAPI/fix/prism-update-examples
vigneshk-tw Sep 26, 2024
92632b8
Added OAS release placeholder file
Sep 26, 2024
75a2e19
Merge pull request #637 from XeroAPI/PETOSS-588-Release-action-OAS
sangeet-joy-tw Sep 26, 2024
bdf4201
Feat: Added the semantic release code
Sep 27, 2024
1f2e3d8
docs: updated the gitignore
Sep 27, 2024
ab57939
Merge pull request #640 from XeroAPI/PETOSS-588-semantic-release-setup
sangeet-joy-tw Sep 27, 2024
e266ff2
Fix: removed the git fetch command (#641)
sangeet-joy-tw Sep 27, 2024
5c916cb
ci: semantic release config updates (#642)
sangeet-joy-tw Oct 3, 2024
8bbf8e4
PETOSS 588 | Pipeline | OAS version update for all spec yaml files (#…
sangeet-joy-tw Oct 15, 2024
f1f4f35
PETOSS 536 | Open API pipeline workflow on PR raise (#678)
sangeet-joy-tw Oct 17, 2024
800cd7a
ci: commitlint step added in PR
Oct 17, 2024
8a3c151
Merge pull request #681 from XeroAPI/PETOSS-588-commitlinting-pipeline
sangeet-joy-tw Oct 18, 2024
98d2e71
ci: updated PR health check trigger condition
Oct 21, 2024
e2bf471
Merge pull request #682 from XeroAPI/PETOSS-588-update-trigger-condition
sangeet-joy-tw Oct 21, 2024
a468fc6
feat: request format has been updated from byte to binary for applica…
Sep 25, 2024
b4cb026
ci: updated the read me typo
Nov 4, 2024
5836221
ci: updated the read me.
sangeet-joy-tw Nov 4, 2024
fdc5a80
ci: typo fix read me
Nov 4, 2024
65430af
ci: typo fix read me
sangeet-joy-tw Nov 4, 2024
14b86c9
Merge branch 'master' into fix/byte-to-binary-changes
vigneshk-tw Nov 4, 2024
9d78edc
Merge pull request #683 from XeroAPI/fix/byte-to-binary-changes
vigneshk-tw Nov 4, 2024
eca2128
feat: trigger commitlint check only on pr
vigneshk-tw Nov 5, 2024
e949a3f
feat: testing commit to trigger on local branch
vigneshk-tw Nov 5, 2024
5294023
feat: revert testing commit to trigger on local branch
vigneshk-tw Nov 5, 2024
e8c221a
Merge pull request #692 from XeroAPI/fix/trigger-commitlint-on-pr-1
vigneshk-tw Nov 5, 2024
6ff4a91
feat: format open api using yq
vigneshk-tw Nov 6, 2024
15e691b
feat: remove unused formatting in yq
vigneshk-tw Nov 6, 2024
e3f4d1b
feat: use pretty print for proper formatting
vigneshk-tw Nov 6, 2024
429bfd6
feat: removed additional tab added
vigneshk-tw Nov 6, 2024
34213f6
Merge pull request #693 from XeroAPI/fix/yq-formatting
vigneshk-tw Nov 6, 2024
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"
},
"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/OAS-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Create OAS release

on:
workflow_dispatch:

jobs:
OAS-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
107 changes: 107 additions & 0 deletions .github/workflows/pr-health-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
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

- name: Install dependencies
run: npm ci

- name: Run commitlint on PR commits
if: github.event_name == 'pull_request'
run: |
npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose

# ***** YAML Linting steps are disabled for now *****



# - name: Install Open API yaml linter
# run: npm i -g @quobix/vacuum

# - name: Run open API validation for yamls
# run: |
# docker run --rm -v ${PWD}:/local openapitools/openapi-generator-cli:v4.3.1 validate -i /local/xero_accounting.yaml
# docker run --rm -v ${PWD}:/local openapitools/openapi-generator-cli:v4.3.1 validate -i /local/xero_assets.yaml
# docker run --rm -v ${PWD}:/local openapitools/openapi-generator-cli:v4.3.1 validate -i /local/xero_bankfeeds.yaml
# docker run --rm -v ${PWD}:/local openapitools/openapi-generator-cli:v4.3.1 validate -i /local/xero_files.yaml
# docker run --rm -v ${PWD}:/local openapitools/openapi-generator-cli:v4.3.1 validate -i /local/xero-app-store.yaml
# docker run --rm -v ${PWD}:/local openapitools/openapi-generator-cli:v4.3.1 validate -i /local/xero-finance.yaml
# docker run --rm -v ${PWD}:/local openapitools/openapi-generator-cli:v4.3.1 validate -i /local/xero-identity.yaml
# docker run --rm -v ${PWD}:/local openapitools/openapi-generator-cli:v4.3.1 validate -i /local/xero-payroll-au.yaml
# docker run --rm -v ${PWD}:/local openapitools/openapi-generator-cli:v4.3.1 validate -i /local/xero-payroll-nz.yaml
# docker run --rm -v ${PWD}:/local openapitools/openapi-generator-cli:v4.3.1 validate -i /local/xero-payroll-uk.yaml
# docker run --rm -v ${PWD}:/local openapitools/openapi-generator-cli:v4.3.1 validate -i /local/xero-projects.yaml
# working-directory: ${{ github.workspace }}

# - name: Run linting
# run: |
# vacuum lint -d -e 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



# ****** Linting steps are disabled for now *******

- 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
uses: codex-/return-dispatch@v2
id: return_dispatch
with:
token: ${{ steps.get_access_token.outputs.result }}
repo: xeroapi-sdk-codegen
owner: xero-internal
workflow: pr.yml
ref: refs/heads/master
workflow_inputs: >
{
"branch_name": "${{ github.event_name == 'pull_request' && github.head_ref || 'master' }}"
}

- name: Checking SDK health status
uses: Codex-/[email protected]
with:
token: ${{ steps.get_access_token.outputs.result }}
repo: xeroapi-sdk-codegen
owner: xero-internal
run_id: ${{ steps.return_dispatch.outputs.run_id }}

166 changes: 166 additions & 0 deletions .github/workflows/update-OAS-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
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 "[email protected]"

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: Auto Merge PR & delete branch
run: |

if [ -z "${{steps.identify_PR_number.outputs.PR_NUMBER}}" ]; then
echo "No PR found for branch: ${{steps.identify_branch_name.outputs.branchName}}"
exit 1
fi

echo "Merging the PR: ${{steps.identify_PR_number.outputs.PR_NUMBER}}....."

gh pr merge ${{steps.identify_PR_number.outputs.PR_NUMBER}} --merge --admin --delete-branch --repo ${{github.repository}}

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}}
Loading
Loading