From a7d9df7a9bfd8873d53e66c6ae64e21fe6fd45aa Mon Sep 17 00:00:00 2001 From: Jaden Kodjo Miles Date: Thu, 3 Oct 2024 10:47:30 +0000 Subject: [PATCH] - Added statusLabel action input - Removed logMessage and status validation - Added workflow to test --- .github/workflows/port-update-test.yml | 41 +++++++++++++++++++ package-lock.json | 25 +++++------ package.json | 2 +- .../UpdateRunOperation/UpdateRunOperation.ts | 5 +-- src/types.ts | 1 + 5 files changed, 57 insertions(+), 17 deletions(-) create mode 100644 .github/workflows/port-update-test.yml diff --git a/.github/workflows/port-update-test.yml b/.github/workflows/port-update-test.yml new file mode 100644 index 0000000..526545b --- /dev/null +++ b/.github/workflows/port-update-test.yml @@ -0,0 +1,41 @@ +name: Port Update Test + +on: + push: + branches: + - PORT-10327-bug-cannot-update-certain-fields-from-github-action # Trigger only for this branch + workflow_dispatch: # Allows manual triggering from the Actions tab + +jobs: + test-port-update: + runs-on: ubuntu-latest + + steps: + # Step 1: Checkout the code + - name: Checkout code + uses: actions/checkout@v2 + + # Step 2: Set up Node.js environment + - name: Set up Node.js + uses: actions/setup-node@v2 + with: + node-version: '16' + + # Step 3: Install dependencies + - name: Install dependencies + run: npm install + + # Step 4: Run the Port GitHub Action test + - name: Run Port Action for Update Run + uses: port-labs/port-github-action@v1 + with: + clientId: ${{ secrets.PORT_CLIENT_ID }} # Set these secrets in GitHub + clientSecret: ${{ secrets.PORT_CLIENT_SECRET }} + baseUrl: 'https://api.getport.io' + runId: 'r_QOz6WoOB1Q2lmhZZ' # Test run ID + status: 'SUCCESS' + statusLabel: 'Completed successfully' + logMessage: 'Test log message' + link: 'https://github.com/port-labs/port-github-action' + summary: 'This is a summary' + diff --git a/package-lock.json b/package-lock.json index ae2aa0f..d29c9e0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "port-github-action", - "version": "1.1.0", + "version": "1.1.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "port-github-action", - "version": "1.1.0", + "version": "1.1.1", "license": "Apache-2.0", "dependencies": { "@actions/core": "^1.10.0", @@ -24,7 +24,7 @@ "eslint-config-airbnb-typescript": "^17.0.0", "eslint-config-prettier": "^8.4.0", "eslint-plugin-github": "^4.10.2", - "eslint-plugin-jest": "^28.3.0", + "eslint-plugin-jest": "^28.8.3", "eslint-plugin-prettier": "^4.0.0", "jest": "^29.7.0", "js-yaml": "^4.1.0", @@ -4330,18 +4330,19 @@ "dev": true }, "node_modules/eslint-plugin-jest": { - "version": "28.3.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-28.3.0.tgz", - "integrity": "sha512-5LjCSSno8E+IUCOX4hJiIb/upPIgpkaDEcaN/40gOcw26t/5UTLHFc4JdxKjOOvGTh0XdCu+fNr0fpOVNvcxMA==", + "version": "28.8.3", + "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-28.8.3.tgz", + "integrity": "sha512-HIQ3t9hASLKm2IhIOqnu+ifw7uLZkIlR7RYNv7fMcEi/p0CIiJmfriStQS2LDkgtY4nyLbIZAD+JL347Yc2ETQ==", "dev": true, + "license": "MIT", "dependencies": { - "@typescript-eslint/utils": "^6.0.0" + "@typescript-eslint/utils": "^6.0.0 || ^7.0.0 || ^8.0.0" }, "engines": { "node": "^16.10.0 || ^18.12.0 || >=20.0.0" }, "peerDependencies": { - "@typescript-eslint/eslint-plugin": "^6.0.0 || ^7.0.0", + "@typescript-eslint/eslint-plugin": "^6.0.0 || ^7.0.0 || ^8.0.0", "eslint": "^7.0.0 || ^8.0.0 || ^9.0.0", "jest": "*" }, @@ -13024,12 +13025,12 @@ } }, "eslint-plugin-jest": { - "version": "28.3.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-28.3.0.tgz", - "integrity": "sha512-5LjCSSno8E+IUCOX4hJiIb/upPIgpkaDEcaN/40gOcw26t/5UTLHFc4JdxKjOOvGTh0XdCu+fNr0fpOVNvcxMA==", + "version": "28.8.3", + "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-28.8.3.tgz", + "integrity": "sha512-HIQ3t9hASLKm2IhIOqnu+ifw7uLZkIlR7RYNv7fMcEi/p0CIiJmfriStQS2LDkgtY4nyLbIZAD+JL347Yc2ETQ==", "dev": true, "requires": { - "@typescript-eslint/utils": "^6.0.0" + "@typescript-eslint/utils": "^6.0.0 || ^7.0.0 || ^8.0.0" } }, "eslint-plugin-jsx-a11y": { diff --git a/package.json b/package.json index be0272d..fbeedaf 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "eslint-config-airbnb-typescript": "^17.0.0", "eslint-config-prettier": "^8.4.0", "eslint-plugin-github": "^4.10.2", - "eslint-plugin-jest": "^28.3.0", + "eslint-plugin-jest": "^28.8.3", "eslint-plugin-prettier": "^4.0.0", "jest": "^29.7.0", "js-yaml": "^4.1.0", diff --git a/src/operations/UpdateRunOperation/UpdateRunOperation.ts b/src/operations/UpdateRunOperation/UpdateRunOperation.ts index 07d7ec6..4c941fe 100644 --- a/src/operations/UpdateRunOperation/UpdateRunOperation.ts +++ b/src/operations/UpdateRunOperation/UpdateRunOperation.ts @@ -19,10 +19,6 @@ export default class UpdateActionOperation implements IOperation { }; private parseInput = (): RunToUpdate => { - if (!this.input.logMessage && !this.input.status) { - throw new Error('PATCH_RUN Operation - message or status is required'); - } - if (this.input.status && !STATUS_OPTIONS.includes(this.input.status)) { throw new Error('PATCH_RUN Operation - status must be one of SUCCESS or FAILURE'); } @@ -30,6 +26,7 @@ export default class UpdateActionOperation implements IOperation { return { ...(this.input.logMessage && { logMessage: this.input.logMessage }), ...(this.input.status && { status: this.input.status }), + ...(this.input.statusLabel && { statusLabel: this.input.statusLabel }), ...(this.input.link && { link: this.parseLinkInput(this.input.link) }), ...(this.input.summary && { summary: this.input.summary }), ...(this.input.externalRunId && { externalRunId: this.input.externalRunId }), diff --git a/src/types.ts b/src/types.ts index 2c33ba5..891e58d 100644 --- a/src/types.ts +++ b/src/types.ts @@ -107,6 +107,7 @@ export type ActionInput = { entities: string; logMessage?: string; status?: 'SUCCESS' | 'FAILURE'; + statusLabel?: string; link?: string; summary?: string; externalRunId?: string;