Skip to content

Commit

Permalink
Added error conditions with custom error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
bhavani-velivala-sn committed Sep 16, 2022
1 parent af2e8f3 commit 0f57435
Show file tree
Hide file tree
Showing 4 changed files with 286 additions and 148 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Test


on:
workflow_dispatch:


jobs:

build:
name: Build
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set Node.js 12.x
uses: actions/setup-node@v1
with:
node-version: 12.x

- name: Install dependencies
run: npm ci

- name: Compile
run: npm run build


changeApproval:
name: ServiceNow Change Approval
needs: build
runs-on: ubutun-latest

steps:
- name: ServiceNow Change Approval
uses: ServiceNow/[email protected]
with:
devops-integration-user-name: ${{ secrets.SN_DEVOPS_USER }}
devops-integration-user-password: ${{ secrets.SN_DEVOPS_PASSWORD }}
instance-url: ${{ secrets.SN_INSTANCE_URL }}
tool-id: ${{ secrets.SN_ORCHESTRATION_TOOL_ID }}
context-github: ${{ toJSON(github) }}
job-name: 'ServiceNow Change Approval'
change-request: '{"setCloseCode":"true","attributes":{"short_description":"Automated Software Deployment","description":"Automated Software Deployment.","assignment_group":"a715cd759f2002002920bde8132e7018","implementation_plan":"Software update is tested and results can be found in Test Summaries Tab; When the change is approved the implementation happens automated by the CICD pipeline within the change planned start and end time window.","backout_plan":"When software fails in production, the previous software release will be re-deployed.","test_plan":"Testing if the software was successfully deployed"}}'
interval: '100'
timeout: '3600'

deploy:
name: Deploy
needs: changeApproval
runs-on: ubutun-latest

steps:
- name: Run Deployment Script
run: echo "Deployment Finished....."
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ServiceNow DevOps Change GitHub Action

This custom action needs to be added at step level in a job to create change in ServiceNow instance.
This custom action needs to be added at step level in a job to create change in ServiceNow instance. Using this custom action in parallel jobs is not supported.

# Usage
## Step 1: Prepare values for setting up your secrets for Actions
Expand All @@ -17,10 +17,14 @@ Create secrets called
- `SN_INSTANCE_URL` your ServiceNow instance URL, for example **https://test.service-now.com**
- `SN_ORCHESTRATION_TOOL_ID` only the **sys_id** is required for the GitHub tool created in your ServiceNow instance

## Step 3: Configure the GitHub Action if need to adapt for your needs or workflows
## Step 3: Identify upstream job that must complete successfully before the job using this custom action will run
Use needs to configure the identified upstream job. See [test.yml](.github/workflows/test.yml) for usage.

## Step 4: Configure the GitHub Action if need to adapt for your needs or workflows
```yaml
deploy:
name: Deploy
needs: <upstream job>
runs-on: ubuntu-latest
steps:
- name: ServiceNow Change
Expand Down
Loading

0 comments on commit 0f57435

Please sign in to comment.