From cd4f290ec130cf7aff4357d919c5309e1a6418db Mon Sep 17 00:00:00 2001 From: lilcly <49772579+lilcly@users.noreply.github.com> Date: Mon, 18 Sep 2023 09:38:16 -0700 Subject: [PATCH 1/6] Create pipeline.yml --- .github/workflows/pipeline.yml | 135 +++++++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 .github/workflows/pipeline.yml diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml new file mode 100644 index 00000000..b735adba --- /dev/null +++ b/.github/workflows/pipeline.yml @@ -0,0 +1,135 @@ +name: ServiceNow GitHub Actions Demo + +on: + pull_request: + push: + branches: + - master + +jobs: + build: + # Purpose of this job is to Apply Remote Changes for the branch triggering + # the pipeline build to the Dev instance, then publish the application to + # app repo using the template versioning format. + name: Publish from Dev + runs-on: ubuntu-latest + # Below line can be used to set conditionals for modifying your pipeline as needed. + # if: ${{ github.event_name == 'pull_request'}} + + steps: + + - name: ServiceNow CI/CD Apply Changes + uses: ServiceNow/sncicd-apply-changes@2.0.0 + env: + nowUsername: ${{ secrets.SN_USERNAME }} + nowPassword: ${{ secrets.SN_PASSWORD }} + nowSourceInstance: ${{ secrets.SN_DEV_INSTANCE }} + appSysID: ${{ secrets.SN_APP_SYSID }} + + - name: ServiceNow CI/CD Publish App + id: publish_app + uses: ServiceNow/sncicd-publish-app@2.0.1 + with: + versionTemplate: 1.1 + versionFormat: template + # Optional, add +X to version number. Default: 1 + # incrementBy: X + env: + nowUsername: ${{ secrets.SN_USERNAME }} + nowPassword: ${{ secrets.SN_PASSWORD }} + nowSourceInstance: ${{ secrets.SN_DEV_INSTANCE }} + appSysID: ${{ secrets.SN_APP_SYSID }} + + # This is required to pass the version number output from Publish App + # to the input for Install App in the next job! This is because the jobs + # run on different Linux instances, so without this Install App won't know + # what to install. + outputs: + publishversion: ${{ steps.publish_app.outputs.newVersion }} + + test: + # Purpose of this job is to Install App from the app repo for the version + # published in the build job to a Test instance, then run an ATF Test Suite + # associated with the app. If Test Suite fails, the app should be Rolled Back + # to clean up the persistent Test environment. + needs: build + name: Run ATF in Test + runs-on: ubuntu-latest + # Below line can be used to set conditionals for modifying your pipeline as needed. + # if: ${{ github.event_name == 'pull_request'}} + + steps: + + - name: ServiceNow CI/CD Install App + id: install_app + uses: ServiceNow/sncicd-install-app@2.0.0 + with: + version: ${{ needs.build.outputs.publishversion }} + # Only applicable if Application Customization is active. + # Version of the base application on which to apply the customizations +# baseAppVersion: '1.2.3' + # Only applicable if Application Customization is active and the associated + # application is a higher version than the currently installed version + # Default: false + autoUpgradeBaseApp: false + env: + nowUsername: ${{ secrets.SN_USERNAME }} + nowPassword: ${{ secrets.SN_PASSWORD }} + nowInstallInstance: ${{ secrets.SN_TEST_INSTANCE }} + appSysID: ${{ secrets.SN_APP_SYSID }} + + - name: ServiceNow CI/CD Run ATF Test Suite + uses: ServiceNow/sncicd-tests-run@2.0.0 + with: + testSuiteSysId: ${{ secrets.SN_ATFTESTSUITE_SYSID }} + env: + nowUsername: ${{ secrets.SN_USERNAME }} + nowPassword: ${{ secrets.SN_PASSWORD }} + nowInstallInstance: ${{ secrets.SN_TEST_INSTANCE }} + + - name: ServiceNow CI/CD Rollback App + if: ${{ failure() && steps.install_app.outputs.rollbackVersion }} + uses: ServiceNow/sncicd-rollback-app@2.0.0 + with: + version: ${{steps.install_app.outputs.rollbackVersion}} + env: + nowUsername: ${{ secrets.SN_USERNAME }} + nowPassword: ${{ secrets.SN_PASSWORD }} + nowInstallInstance: ${{ secrets.SN_TEST_INSTANCE }} + appSysID: ${{ secrets.SN_APP_SYSID }} + + # This is required to pass the version number output from Publish App + # to the input for Install App in the next job! This is because the jobs + # run on different Linux instances, so without this Install App won't know + # what to install. + outputs: + publishversion: ${{ needs.build.outputs.publishversion }} + + deployprod: + # Purpose of this job is to Install App to a Prod instance. This should only + # trigger if the feature branch has been merged to master after a successfully + # completed pull request, hence the conditional for push to master. In other words, + # the first two jobs run on CI, then all three jobs run on CD. + needs: test + name: Deploy to Prod + runs-on: ubuntu-latest + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} + steps: + + - name: ServiceNow CI/CD Install App + id: install_app_prod + uses: ServiceNow/sncicd-install-app@2.0.0 + with: + version: ${{ needs.test.outputs.publishversion }} + # Only applicable if Application Customization is active. + # Version of the base application on which to apply the customizations +# baseAppVersion: '1.2.3' + # Only applicable if Application Customization is active and the associated + # application is a higher version than the currently installed version + # Default: false +# autoUpgradeBaseApp: true + env: + nowUsername: ${{ secrets.SN_USERNAME }} + nowPassword: ${{ secrets.SN_PASSWORD }} + nowInstallInstance: ${{ secrets.SN_PROD_INSTANCE }} + appSysID: ${{ secrets.SN_APP_SYSID }} From 69a13dc57dbcd9ade49f9df95d0ab139bc2ac9ad Mon Sep 17 00:00:00 2001 From: lilcly <49772579+lilcly@users.noreply.github.com> Date: Mon, 18 Sep 2023 09:49:20 -0700 Subject: [PATCH 2/6] Update pipeline.yml --- .github/workflows/pipeline.yml | 109 ++------------------------------- 1 file changed, 4 insertions(+), 105 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index b735adba..538d1132 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -21,24 +21,10 @@ jobs: - name: ServiceNow CI/CD Apply Changes uses: ServiceNow/sncicd-apply-changes@2.0.0 env: - nowUsername: ${{ secrets.SN_USERNAME }} - nowPassword: ${{ secrets.SN_PASSWORD }} - nowSourceInstance: ${{ secrets.SN_DEV_INSTANCE }} - appSysID: ${{ secrets.SN_APP_SYSID }} - - - name: ServiceNow CI/CD Publish App - id: publish_app - uses: ServiceNow/sncicd-publish-app@2.0.1 - with: - versionTemplate: 1.1 - versionFormat: template - # Optional, add +X to version number. Default: 1 - # incrementBy: X - env: - nowUsername: ${{ secrets.SN_USERNAME }} - nowPassword: ${{ secrets.SN_PASSWORD }} - nowSourceInstance: ${{ secrets.SN_DEV_INSTANCE }} - appSysID: ${{ secrets.SN_APP_SYSID }} + nowUsername: ${{ secrets.NOW_USERNAME }} + nowPassword: ${{ secrets.NOW_PASSWORD }} + nowSourceInstance: ${{ secrets.NOW_SOURCE_INSTANCE }} + appSysID: ${{ secrets.APP_SYS_ID }} # This is required to pass the version number output from Publish App # to the input for Install App in the next job! This is because the jobs @@ -46,90 +32,3 @@ jobs: # what to install. outputs: publishversion: ${{ steps.publish_app.outputs.newVersion }} - - test: - # Purpose of this job is to Install App from the app repo for the version - # published in the build job to a Test instance, then run an ATF Test Suite - # associated with the app. If Test Suite fails, the app should be Rolled Back - # to clean up the persistent Test environment. - needs: build - name: Run ATF in Test - runs-on: ubuntu-latest - # Below line can be used to set conditionals for modifying your pipeline as needed. - # if: ${{ github.event_name == 'pull_request'}} - - steps: - - - name: ServiceNow CI/CD Install App - id: install_app - uses: ServiceNow/sncicd-install-app@2.0.0 - with: - version: ${{ needs.build.outputs.publishversion }} - # Only applicable if Application Customization is active. - # Version of the base application on which to apply the customizations -# baseAppVersion: '1.2.3' - # Only applicable if Application Customization is active and the associated - # application is a higher version than the currently installed version - # Default: false - autoUpgradeBaseApp: false - env: - nowUsername: ${{ secrets.SN_USERNAME }} - nowPassword: ${{ secrets.SN_PASSWORD }} - nowInstallInstance: ${{ secrets.SN_TEST_INSTANCE }} - appSysID: ${{ secrets.SN_APP_SYSID }} - - - name: ServiceNow CI/CD Run ATF Test Suite - uses: ServiceNow/sncicd-tests-run@2.0.0 - with: - testSuiteSysId: ${{ secrets.SN_ATFTESTSUITE_SYSID }} - env: - nowUsername: ${{ secrets.SN_USERNAME }} - nowPassword: ${{ secrets.SN_PASSWORD }} - nowInstallInstance: ${{ secrets.SN_TEST_INSTANCE }} - - - name: ServiceNow CI/CD Rollback App - if: ${{ failure() && steps.install_app.outputs.rollbackVersion }} - uses: ServiceNow/sncicd-rollback-app@2.0.0 - with: - version: ${{steps.install_app.outputs.rollbackVersion}} - env: - nowUsername: ${{ secrets.SN_USERNAME }} - nowPassword: ${{ secrets.SN_PASSWORD }} - nowInstallInstance: ${{ secrets.SN_TEST_INSTANCE }} - appSysID: ${{ secrets.SN_APP_SYSID }} - - # This is required to pass the version number output from Publish App - # to the input for Install App in the next job! This is because the jobs - # run on different Linux instances, so without this Install App won't know - # what to install. - outputs: - publishversion: ${{ needs.build.outputs.publishversion }} - - deployprod: - # Purpose of this job is to Install App to a Prod instance. This should only - # trigger if the feature branch has been merged to master after a successfully - # completed pull request, hence the conditional for push to master. In other words, - # the first two jobs run on CI, then all three jobs run on CD. - needs: test - name: Deploy to Prod - runs-on: ubuntu-latest - if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} - steps: - - - name: ServiceNow CI/CD Install App - id: install_app_prod - uses: ServiceNow/sncicd-install-app@2.0.0 - with: - version: ${{ needs.test.outputs.publishversion }} - # Only applicable if Application Customization is active. - # Version of the base application on which to apply the customizations -# baseAppVersion: '1.2.3' - # Only applicable if Application Customization is active and the associated - # application is a higher version than the currently installed version - # Default: false -# autoUpgradeBaseApp: true - env: - nowUsername: ${{ secrets.SN_USERNAME }} - nowPassword: ${{ secrets.SN_PASSWORD }} - nowInstallInstance: ${{ secrets.SN_PROD_INSTANCE }} - appSysID: ${{ secrets.SN_APP_SYSID }} From 9c466f632c5b5c67ee77e438be12da29e1eda8cf Mon Sep 17 00:00:00 2001 From: lilcly <49772579+lilcly@users.noreply.github.com> Date: Mon, 18 Sep 2023 09:54:09 -0700 Subject: [PATCH 3/6] Update pipeline.yml --- .github/workflows/pipeline.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 538d1132..4b37460f 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -32,3 +32,5 @@ jobs: # what to install. outputs: publishversion: ${{ steps.publish_app.outputs.newVersion }} + +#test From 48d9acfcf677faf2ff8ff4dc82a46ff0ef499ba2 Mon Sep 17 00:00:00 2001 From: lilcly <49772579+lilcly@users.noreply.github.com> Date: Mon, 18 Sep 2023 10:03:06 -0700 Subject: [PATCH 4/6] Update pipeline.yml --- .github/workflows/pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 4b37460f..8ce8ddc2 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -33,4 +33,4 @@ jobs: outputs: publishversion: ${{ steps.publish_app.outputs.newVersion }} -#test +#test again From e3b8d59c21a5e24461227b691429b6e01004b38d Mon Sep 17 00:00:00 2001 From: lilcly <49772579+lilcly@users.noreply.github.com> Date: Thu, 21 Sep 2023 07:34:54 -0700 Subject: [PATCH 5/6] Update pipeline.yml --- .github/workflows/pipeline.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 8ce8ddc2..cbef52d6 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -25,6 +25,19 @@ jobs: nowPassword: ${{ secrets.NOW_PASSWORD }} nowSourceInstance: ${{ secrets.NOW_SOURCE_INSTANCE }} appSysID: ${{ secrets.APP_SYS_ID }} + - name: ServiceNow CI/CD Publish App + id: publish_app + uses: ServiceNow/sncicd-publish-app@2.0.1 + with: + versionTemplate: 1.1 + versionFormat: template + # Optional, add +X to version number. Default: 1 + # incrementBy: X + env: + nowUsername: ${{ secrets.SN_USERNAME }} + nowPassword: ${{ secrets.SN_PASSWORD }} + nowSourceInstance: ${{ secrets.SN_DEV_INSTANCE }} + appSysID: ${{ secrets.SN_APP_SYSID }} # This is required to pass the version number output from Publish App # to the input for Install App in the next job! This is because the jobs From b5b43fb37c05678ddc54eff5af8ae185739f75b5 Mon Sep 17 00:00:00 2001 From: lilcly <49772579+lilcly@users.noreply.github.com> Date: Thu, 21 Sep 2023 07:40:49 -0700 Subject: [PATCH 6/6] Update pipeline.yml --- .github/workflows/pipeline.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index cbef52d6..1e597c5d 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -34,10 +34,10 @@ jobs: # Optional, add +X to version number. Default: 1 # incrementBy: X env: - nowUsername: ${{ secrets.SN_USERNAME }} - nowPassword: ${{ secrets.SN_PASSWORD }} - nowSourceInstance: ${{ secrets.SN_DEV_INSTANCE }} - appSysID: ${{ secrets.SN_APP_SYSID }} + nowUsername: ${{ secrets.NOW_USERNAME }} + nowPassword: ${{ secrets.NOW_PASSWORD }} + nowSourceInstance: ${{ secrets.NOW_SOURCE_INSTANCE }} + appSysID: ${{ secrets.APP_SYS_ID }} # This is required to pass the version number output from Publish App # to the input for Install App in the next job! This is because the jobs