Setting up your first CI/CD pipeline with GitHub Actions
my name is charn and i'm product manager for servicenow's source control and ci cd features today i'm going to be showing you a demo of starting from a fresh global app and setting up your first ci cd pipeline using github actions which we released recently github actions or wrap the cicd apis that we released in orlando and help you to get started faster than setting up your first pipeline for a linked source control git repo so setting up wise i have my dev business here where we will be using studio to create an application i have my test instance here where i have an atf test suite set up already i have my prod instance where we will be checking the version of the application that's being deployed as part of the cd uh pipeline and here we can see on marketplace the servicenow ci cd actions that we have shipped recently on top of the actions which will allow you to chain together steps within a pipeline we've also delivered a workflow uh template for you to just copy and paste as a part of getting started faster you can of course iterate and modify this to fit your particular organization's needs so let's get started if we head back to my dev business and go to studio we're going to start by creating an application and we're going to say this is a my github action demo and we're going to be creating a global app to enable this radio button there is a system properties flag that you can set so that you can create global apps to track your global files and now that i have my app created the first thing i'm going to do with the app is to link to source control so here you see we need a url coming back to github we can create a new repository i'm going to name it the same just to keep it consistent and great now i have my git repos url we're going to use the https option here for linking to our git repo and since this is my first time linking to the repo i'm okay with linking it to the master branch we're not going to use a mid server because my github.com kit repo is not mostly behind a corporate firewall and i have already previously set up my credential for my particular account using my personal access token so we're going to link it now and i'll be able to see that i am linked to source control on my master branch down here in the bottom right corner and we check back to my repo and refresh the page we'll see that my app is here represented as this id of the global app one of the first things that we're going to do here is to set up our ci cd pipeline as well as sequence representing the environment variables that i want to feed into my pipeline if you go to actions there are many templates to choose from to generate we're going to start with our pipeline.em file and go back to our pipeline template and just copy paste it just to really quickly walk through what our pipeline template does we have three different jobs firstly the pipeline triggers on every pull request as well as pushes through the master branch our three jobs are build test and deploy the product in our build step we are applying remote changes from remote repo down to an instance then we're going to be publishing the application with a particular version if that's successful then the test stage will run where we will be installing that version of the app into our test instance triggering the atf test suite that i've already got set up there if that passes then it will not run through the rollback action but if it fails then we will roll back the environment to clean it up and lastly i have a deployed production job here that will only run if this is a push to master branch and this installed that version of the application that we've just gone through the ci before into my production instance if you wanted to modify the pipeline yourself you can always search for our servicenow cicd github actions and plug them directly into your pipeline i already have everything i need so i'm actually just going to commit directly to the last branch the second step that i need to do as a part of setting up my fresh repo here is configuring secrets these secrets are passed in as environment variables so could include both my credentials for my service accounts for my instances as well as other ids for the various steps um represented within the workflow so i'm going to take a show out here to plug in all of my secrets oh great now that i have all my secrets in i am ready to start the bottom work back to my dev instance here i'm going to first apply remote changes to pull down any new commits that i've made to my master branch i am then going to create a new branch representing a story off of my backlog as part of developing the feature for the story i'm going to be creating a new scripting booth a global script included and terrific we can see now here that we have a new new global script include and we're going to be committing and pushing these changes up to get revolt one of the features that we delivered in orlando was selective commits if we had more changes we would see more options here that i can choose the bitcoin for now we're just going to be completing the sponsor conclude great let's take a look at our repo we can see here that our new feature branch is present on instance now i have nothing else i want to change to it so let's kick off the pull request we'll see here that a build has been started based on the workflow pipeline that i just set up as a part of actions and in github we can click into details and take a look at the actual steps that are running so my first job i am publishing uh from the dev business after doing apply remote changes down from the remote repo to the local instance my dev business in this case and we'll see here that we were able to successfully apply remote changes uh now it is publishing a version of the application to the app repo perfect looks like we were able to publish the app we are also exporting the version of the application that i just published this poet this was defined in the pipeline earlier and now we can run the second job which will install the application on the app repo into your test environment looks like the installation was successful and we are now running our atf test suite in my test environment the example here is a very trivial test suite and that has passed successfully and therefore we don't need to do a rollback and again i am exporting the version so that i can continue to use it later we are skipping deploy to prod because again uh this job only triggers if it's a push to the master branch and this is important question so coming back to a pull request we'll note that the build has passed and that's great and we're ready to merge for now one of the things that you will want to do before completing the pull request and therefore the merge is to switch your branch back to the master bench and the reason for this is so that you can run a cd build off of your master bench great so now that we're on our master venture note that the master branch does not have the global script include that we just created on the feature range and we're not going to complete the pull request and merge the feature branch into your master branch terrific our pull request is now complete and we can take a look here in actions and we'll see here that the continuous delivery part of the pipeline is starting so now we're going to republish the master branch now from the dev pipeline as another application version and go through perfect we can see the first two this stages have completed and because this is emerging to the master branch we are triggering our third job which is to install this application to the productions terrific so that looks like that was successful and let's check my production instance now we were to refresh this in my company applications since it is a global app i can take a look at my installed applications and find the github demo and see here that version 2425 was published based off the pipeline so thank you so much for watching that was an example of creating a new global app uh setting up your first ci cd pipeline uh based on the pipeline template and the actions that we've published as well as running through a github flow for a feature branch merging into your master branch via pull request triggering a ci build passing that ci build merging into the master branch triggering a cd build and finally deploying into your production instance uh so i hope that you can use the give up actions to set up your first pipelines and feel free to contribute to the open source project as well for the actions thanks so much
https://www.youtube.com/watch?v=OZtm4tgHVo4