{"id":105839,"date":"2025-03-11T10:19:51","date_gmt":"2025-03-11T10:19:51","guid":{"rendered":"https:\/\/www.red-gate.com\/simple-talk\/?p=105839"},"modified":"2025-03-11T10:19:53","modified_gmt":"2025-03-11T10:19:53","slug":"introduction-to-github-actions-part-1-getting-started","status":"publish","type":"post","link":"https:\/\/www.red-gate.com\/simple-talk\/featured\/introduction-to-github-actions-part-1-getting-started\/","title":{"rendered":"Introduction to GitHub Actions Part 1: Getting Started"},"content":{"rendered":"\n<p>GitHub is one of the most popular services on the planet for storing documents. That includes everything from PowerPoint presentations to recipes, but it\u2019s the de facto standard for storing source code. Microsoft purchased GitHub in 2018, and despite that, GitHub has not lost any appreciable popularity among developers.<\/p>\n\n\n\n<p>One of the main benefits of GitHub is full integration with Git. Git repositories are local and single user, but once a git repo is pushed to GitHub, a team can now share the repository and work together.<\/p>\n\n\n\n<p>Storing source code in an online repository like GitHub is the first step. Next, most organizations will want to automate deploying application code and even the infrastructure used to test or host the application. There are many automation products available (also called CI\/CD tools for continuous integration and continuous deployment) such as Azure DevOps Pipelines, Jenkins, Octopus Deploy and many more.<\/p>\n\n\n\n<p>Shortly before Microsoft acquired GitHub in late 2018, GitHub Actions was released. GitHub Actions is a powerful CI\/CD platform that can be used to automate code integration and deployment.<\/p>\n\n\n\n<p>This article series will teach you what you need to know to take advantage of GitHub Actions, especially for deploying database code.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-prerequisites\"><a id=\"post-105839-_dgxkddxja2wv\"><\/a>Prerequisites<\/h2>\n\n\n\n<p>To follow along with this article series, make sure you have:<\/p>\n\n\n<div class=\"block-core-list\">\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/git-scm.com\/book\/en\/v2\/Getting-Started-Installing-Git\">Installed git<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/code.visualstudio.com\/download\">Installed VS Code<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/github.com\/signup?source=login\">Created a GitHub account<\/a><\/li>\n<\/ul>\n<\/div>\n\n\n<p>After installing git, be sure to configure your account. Fill in the correct information and run in command line<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">git config \u2013global user.email \"your_email.com\u201d\n\ngit config --global user.name \"your_name\"<\/pre>\n\n\n\n<p>Which will looks similar to this:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"877\" height=\"99\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/02\/word-image-105839-1.png\" alt=\"\" class=\"wp-image-105840\" srcset=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/02\/word-image-105839-1.png 877w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/02\/word-image-105839-1-300x34.png 300w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/02\/word-image-105839-1-768x87.png 768w\" sizes=\"auto, (max-width: 877px) 100vw, 877px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>Image 1: Adding global configuration to local git<\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-create-a-github-repository\"><a id=\"post-105839-_noyqcy7vpjdr\"><\/a>Create a GitHub repository<\/h2>\n\n\n\n<p>Follow these steps to create a GitHub repo.<\/p>\n\n\n<div class=\"block-core-list\">\n<ul class=\"wp-block-list\">\n<li>On <a href=\"https:\/\/github.com\/\">GitHub.com<\/a>, log in and click the + icon.<\/li>\n<\/ul>\n<\/div>\n\n<div class=\"block-core-list\">\n<ul class=\"wp-block-list\">\n<li>Select <strong>New Repository<\/strong>. <br><img loading=\"lazy\" decoding=\"async\" width=\"962\" height=\"465\" class=\"wp-image-105841\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/02\/word-image-105839-2.png\" srcset=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/02\/word-image-105839-2.png 962w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/02\/word-image-105839-2-300x145.png 300w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/02\/word-image-105839-2-768x371.png 768w\" sizes=\"auto, (max-width: 962px) 100vw, 962px\" \/><strong><br>Image 2: New GitHub repository<\/strong><\/li>\n<\/ul>\n<\/div>\n\n\n<div style=\"height:28px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n<div class=\"block-core-list\">\n<ul class=\"wp-block-list\">\n<li>Type in a name for the repo (My example will use the name \u201c<code>GitHubActionsExample<\/code>\u201d)<\/li>\n<\/ul>\n<\/div>\n\n<div class=\"block-core-list\">\n<ul class=\"wp-block-list\">\n<li>Leave security at <code>Public<\/code> <br><img loading=\"lazy\" decoding=\"async\" width=\"979\" height=\"676\" class=\"wp-image-105842\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/02\/word-image-105839-3.png\" srcset=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/02\/word-image-105839-3.png 979w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/02\/word-image-105839-3-300x207.png 300w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/02\/word-image-105839-3-768x530.png 768w\" sizes=\"auto, (max-width: 979px) 100vw, 979px\" \/><strong><br>Image 3: New GitHub repository settings<\/strong><\/li>\n<\/ul>\n<\/div>\n\n\n<div style=\"height:28px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n<div class=\"block-core-list\">\n<ul class=\"wp-block-list\">\n<li>Click Create repository at the bottom of the page <br><img loading=\"lazy\" decoding=\"async\" width=\"1128\" height=\"496\" class=\"wp-image-105843\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/02\/word-image-105839-4.png\" srcset=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/02\/word-image-105839-4.png 1128w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/02\/word-image-105839-4-300x132.png 300w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/02\/word-image-105839-4-1024x450.png 1024w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/02\/word-image-105839-4-768x338.png 768w\" sizes=\"auto, (max-width: 1128px) 100vw, 1128px\" \/><strong><br>Image 4: Create the repo<\/strong><\/li>\n<\/ul>\n<\/div>\n\n\n<div style=\"height:28px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p><a id=\"post-105839-_nm5j1w9mfctz\"><\/a><\/p>\n\n\n<div class=\"block-core-list\">\n<ul class=\"wp-block-list\">\n<li>GitHub will display some options about connecting to your local git repository.<\/li>\n<\/ul>\n<\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"h-connect-the-online-repository-to-a-local-repository\">Connect the online repository to a local repository<\/h2>\n\n\n\n<p>Follow these steps to pull the repository to the local computer:<\/p>\n\n\n<div class=\"block-core-list\">\n<ul class=\"wp-block-list\">\n<li>Create a folder for your projects<\/li>\n\n\n\n<li>Create a folder for this specific project<\/li>\n\n\n\n<li>Open a command line and navigate to the new folder<\/li>\n\n\n\n<li>In GitHub, copy the code provided to create a local repo<br><br><code>echo \"# GitHubActionsExample\" >> README.md<br>git init<br>git add README.md<br>git commit -m \"first commit\"<br>git branch -M main<br>git remote add origin https:\/\/github.com\/&lt;your repo name>\/GithubActionsExample.git<br>git push - u origin main<\/code><br><\/li>\n<\/ul>\n<\/div>\n\n\n<div style=\"height:31px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n<div class=\"block-core-list\">\n<ul class=\"wp-block-list\">\n<li>Paste the code into the command line window (Note that you may be required to authenticate with GitHub)<\/li>\n\n\n\n<li><img loading=\"lazy\" decoding=\"async\" width=\"1350\" height=\"766\" class=\"wp-image-105846\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/02\/word-image-105839-6.png\" srcset=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/02\/word-image-105839-6.png 1350w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/02\/word-image-105839-6-300x170.png 300w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/02\/word-image-105839-6-1024x581.png 1024w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/02\/word-image-105839-6-768x436.png 768w\" sizes=\"auto, (max-width: 1350px) 100vw, 1350px\" \/><strong>Image 5: Running the code to connect the repo<\/strong><\/li>\n<\/ul>\n<\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"h-github-actions-structure\"><a id=\"post-105839-_57431p35fyg8\"><\/a>GitHub Actions structure<\/h2>\n\n\n\n<p>Automating a deployment \u2013 or anything you wish to automate \u2013 is accomplished by <em>Workflows<\/em> in GitHub Actions. For those of you who love working in code, there is no user interface. Workflow files are yaml.<\/p>\n\n\n\n<p>Creating a new GitHub Actions file is simple. Within the repository, create this folder structure:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">.github\/workflows<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1020\" height=\"295\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/02\/word-image-105839-7.png\" alt=\"\" class=\"wp-image-105848\" srcset=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/02\/word-image-105839-7.png 1020w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/02\/word-image-105839-7-300x87.png 300w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/02\/word-image-105839-7-768x222.png 768w\" sizes=\"auto, (max-width: 1020px) 100vw, 1020px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>Image 6: GitHub Actions file structure<\/strong><\/p>\n\n\n\n<p>Any <code>yaml<\/code> file located in the workflows folder is automatically a GitHub Actions Workflow.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-hello-world\"><a id=\"post-105839-_gps0t2sj4jmu\"><\/a>Hello, world!<\/h2>\n\n\n\n<p>This article series will cover how to create these files, but of course, the first thing to learn when code is involved is printing a \u201cHello, world!\u201d message.<\/p>\n\n\n\n<p>Open VS Code and create a new file. Save it in the new <code>.github\\workflows<\/code> folder with a <code>yaml<\/code> or <code>yml<\/code> extension. Code for this article can be found <a href=\"https:\/\/github.com\/KathiKellenberger\/GitHubActionsExample-Part1\">here<\/a>. Add this code:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">name: Hello, World\n \n# Controls when the workflow will run, in this case manually\non: workflow_dispatch\njobs:\n  PrintHelloWorld:\n    name: Print Hello, World!\n    runs-on: ubuntu-latest\n    steps: \n    - run: echo \"Hello, World!\"<\/pre>\n\n\n\n<p>This should result in the following output:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"904\" height=\"471\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/02\/word-image-105839-8.png\" alt=\"\" class=\"wp-image-105850\" srcset=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/02\/word-image-105839-8.png 904w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/02\/word-image-105839-8-300x156.png 300w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/02\/word-image-105839-8-768x400.png 768w\" sizes=\"auto, (max-width: 904px) 100vw, 904px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>Image 7: The \u201cHello, World!\u201dcode in VS Code<\/strong><\/p>\n\n\n\n<p>Note that white space is critical in yaml. VS Code can help with this, but I find not getting it right is the source of most of the errors I make with yaml.<\/p>\n\n\n\n<p>Save the file. Push to the online repo by typing this into the cmd window, with the project directory base directory in focus:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">git add .\ngit commit -m\"Add a new workflow file\"\ngit push <\/pre>\n\n\n\n<p>You should get output similar to the following. (note, the first statement does not have any output.)<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"799\" height=\"400\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/02\/word-image-105839-9.png\" alt=\"\" class=\"wp-image-105851\" srcset=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/02\/word-image-105839-9.png 799w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/02\/word-image-105839-9-300x150.png 300w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/02\/word-image-105839-9-768x384.png 768w\" sizes=\"auto, (max-width: 799px) 100vw, 799px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>Image 8: Push the code to the online repo<\/strong><\/p>\n\n\n\n<p>If all went well, you should see the workflow in GitHub Actions in the Actions tab. The names of any workflows are listed on the left.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1876\" height=\"562\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/02\/word-image-105839-10.png\" alt=\"\" class=\"wp-image-105853\" srcset=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/02\/word-image-105839-10.png 1876w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/02\/word-image-105839-10-300x90.png 300w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/02\/word-image-105839-10-1024x307.png 1024w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/02\/word-image-105839-10-768x230.png 768w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/02\/word-image-105839-10-1536x460.png 1536w\" sizes=\"auto, (max-width: 1876px) 100vw, 1876px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>Image 9: The published workflow<\/strong><\/p>\n\n\n\n<p>To run the code, click <strong>Run workflow<\/strong> \u2192 <strong>Run workflow<\/strong>.<\/p>\n\n\n\n<p>Within a few seconds, you should see the Workflow in progress:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1392\" height=\"474\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/02\/word-image-105839-11.png\" alt=\"\" class=\"wp-image-105856\" srcset=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/02\/word-image-105839-11.png 1392w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/02\/word-image-105839-11-300x102.png 300w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/02\/word-image-105839-11-1024x349.png 1024w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/02\/word-image-105839-11-768x262.png 768w\" sizes=\"auto, (max-width: 1392px) 100vw, 1392px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>Image 10: The workflow is running<\/strong><\/p>\n\n\n\n<p>If the run is successful, then you\u2019ll see the green checkmark icon.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1369\" height=\"370\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/02\/word-image-105839-12.png\" alt=\"\" class=\"wp-image-105858\" srcset=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/02\/word-image-105839-12.png 1369w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/02\/word-image-105839-12-300x81.png 300w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/02\/word-image-105839-12-1024x277.png 1024w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/02\/word-image-105839-12-768x208.png 768w\" sizes=\"auto, (max-width: 1369px) 100vw, 1369px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>Image 11: The workflow is successful<\/strong><\/p>\n\n\n\n<p>Drill down into the run to see the message.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"897\" height=\"561\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/02\/word-image-105839-13.png\" alt=\"\" class=\"wp-image-105860\" srcset=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/02\/word-image-105839-13.png 897w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/02\/word-image-105839-13-300x188.png 300w, https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2025\/02\/word-image-105839-13-768x480.png 768w\" sizes=\"auto, (max-width: 897px) 100vw, 897px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>Image 12: The message<\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-conclusion\"><a id=\"post-105839-_sq999snot830\"><\/a>Conclusion<\/h2>\n\n\n\n<p>This article walked you through setting up and running your first GitHub Actions Workflow. One of the benefits of GitHub Actions is its simplicity. The Workflow file is simple yaml \u2013 well, until it gets complex!<\/p>\n\n\n\n<p>Workflows must have a VM, called a <em>runner<\/em>, to run on. You can provide your own VMs or use one that is provided by GitHub. The next article in the series will cover GitHub-hosted runners.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>GitHub is one of the most popular services on the planet for storing documents. That includes everything from PowerPoint presentations to recipes, but it\u2019s the de facto standard for storing source code. Microsoft purchased GitHub in 2018, and despite that, GitHub has not lost any appreciable popularity among developers. One of the main benefits of&#8230;&hellip;<\/p>\n","protected":false},"author":110218,"featured_media":105869,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[143512,53],"tags":[5970,5775,159280],"coauthors":[11292],"class_list":["post-105839","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-devops","category-featured","tag-devops","tag-github","tag-kathikellenbergergithubseries"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/105839","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/users\/110218"}],"replies":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/comments?post=105839"}],"version-history":[{"count":9,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/105839\/revisions"}],"predecessor-version":[{"id":105883,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/105839\/revisions\/105883"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/media\/105869"}],"wp:attachment":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/media?parent=105839"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/categories?post=105839"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/tags?post=105839"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/coauthors?post=105839"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}