Skip to content

Commit

Permalink
- Added statusLabel action input
Browse files Browse the repository at this point in the history
- Removed logMessage and status validation
- Added workflow to test
  • Loading branch information
kodjomiles committed Oct 3, 2024
1 parent d388840 commit a7d9df7
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 17 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/port-update-test.yml
Original file line number Diff line number Diff line change
@@ -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'

25 changes: 13 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 1 addition & 4 deletions src/operations/UpdateRunOperation/UpdateRunOperation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,14 @@ 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');
}

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 }),
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export type ActionInput = {
entities: string;
logMessage?: string;
status?: 'SUCCESS' | 'FAILURE';
statusLabel?: string;
link?: string;
summary?: string;
externalRunId?: string;
Expand Down

0 comments on commit a7d9df7

Please sign in to comment.