<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>The Ops Community ⚙️: Jason Purdy</title>
    <description>The latest articles on The Ops Community ⚙️ by Jason Purdy (@purdy).</description>
    <link>https://community.ops.io/purdy</link>
    <image>
      <url>https://community.ops.io/images/UFh61wZevvF_ixhjRdE_NjCicdTvwoGUD1n9thTUDFw/rs:fill:90:90/g:sm/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL3Vz/ZXIvcHJvZmlsZV9p/bWFnZS8xNDcvOGFm/NzhjNzktOTUyYS00/MzI1LWE3ZDItYzg3/MDI5ZmQ2ZTJiLmpw/ZWc</url>
      <title>The Ops Community ⚙️: Jason Purdy</title>
      <link>https://community.ops.io/purdy</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://community.ops.io/feed/purdy"/>
    <language>en</language>
    <item>
      <title>Automatic Checklists with Pull Request Templates</title>
      <dc:creator>Jason Purdy</dc:creator>
      <pubDate>Thu, 09 Jun 2022 17:29:33 +0000</pubDate>
      <link>https://community.ops.io/purdy/automatic-checklists-with-pull-request-templates-21nh</link>
      <guid>https://community.ops.io/purdy/automatic-checklists-with-pull-request-templates-21nh</guid>
      <description>&lt;p&gt;If you haven't read or heard of the &lt;em&gt;&lt;a href="https://www.amazon.com/Checklist-Manifesto-How-Things-Right-ebook/dp/B0030V0PEW"&gt;Checklist Manifesto&lt;/a&gt;&lt;/em&gt; book, it's a great read about how a checklist can help get things right. There's a case study about how a hospital saw decreases in surgery deaths when they employed a checklist.&lt;/p&gt;

&lt;p&gt;At my work, we employ a checklist when it comes to deploying code, which is a part of our pull request process. When someone has code that's ready to ship, they generate a pull request, which has some of these steps:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Get code review&lt;/li&gt;
&lt;li&gt;Present staging server for stakeholder signoff&lt;/li&gt;
&lt;li&gt;Have all stakeholders signoff&lt;/li&gt;
&lt;li&gt;Pick deployment date/time and communicate w/ team that deployment is happening&lt;/li&gt;
&lt;li&gt;Put site in maintenance mode and take backup&lt;/li&gt;
&lt;li&gt;Deploy code&lt;/li&gt;
&lt;li&gt;Make any database/configuration changes&lt;/li&gt;
&lt;li&gt;Final testing on production&lt;/li&gt;
&lt;li&gt;Remove maintenance mode&lt;/li&gt;
&lt;li&gt;Communicate w/ stakeholders that code is live&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You make make this checklist show up automatically with a pull request template. You would create a file called &lt;code&gt;PULL_REQUEST_TEMPLATE.md&lt;/code&gt; and put it your project's &lt;code&gt;.github&lt;/code&gt; folder. Looks something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="gu"&gt;## Description&lt;/span&gt;
&amp;lt;!--
    Describe what this update does.
--&amp;gt;

&amp;lt;!--
    If this pull request closes any issues, please specify here. Otherwise, delete this section.
--&amp;gt;
Closes: #

&lt;span class="gu"&gt;## Testing&lt;/span&gt;
&amp;lt;!--
  Describe what testing you did for this.
--&amp;gt;

&lt;span class="gu"&gt;## Code Deployment Checklist&lt;/span&gt;
&lt;span class="p"&gt; -&lt;/span&gt; [ ] Get code review
&lt;span class="p"&gt; -&lt;/span&gt; [ ] Present staging server for stakeholder signoff
&lt;span class="p"&gt; -&lt;/span&gt; [ ] Have all stakeholders signoff
&lt;span class="p"&gt; -&lt;/span&gt; [ ] Pick deployment date/time and communicate w/ team that deployment is happening
&lt;span class="p"&gt; -&lt;/span&gt; [ ] Put site in maintenance mode and take backup
&lt;span class="p"&gt; -&lt;/span&gt; [ ] Deploy code
&lt;span class="p"&gt; -&lt;/span&gt; [ ] Make any database/configuration changes
&lt;span class="p"&gt; -&lt;/span&gt; [ ] Final testing on production
&lt;span class="p"&gt; -&lt;/span&gt; [ ] Remove maintenance mode
&lt;span class="p"&gt; -&lt;/span&gt; [ ] Communicate w/ stakeholders that code is live

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then whenever you create a pull request in GitHub, the template gets auto-populated like so:&lt;br&gt;
&lt;a href="https://community.ops.io/images/yoQkTnyyWNhGmgnw7blDJ06UOz27MBiSycKsM_pwpTM/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzLzFidzdr/cHJ4dTFwMmNuYm1k/NTBrLnBuZw" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ops.io/images/yoQkTnyyWNhGmgnw7blDJ06UOz27MBiSycKsM_pwpTM/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzLzFidzdr/cHJ4dTFwMmNuYm1k/NTBrLnBuZw" alt="Pull request creation" width="880" height="876"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And when you create the pull request, it looks something like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ops.io/images/80apMbVsc6J6d7zOmRv6VtmLP2_7n-m_ROA1S_vYKdM/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzL3puMDkw/Ym5md3M1YnF1djN1/MTJrLnBuZw" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ops.io/images/80apMbVsc6J6d7zOmRv6VtmLP2_7n-m_ROA1S_vYKdM/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzL3puMDkw/Ym5md3M1YnF1djN1/MTJrLnBuZw" alt="Checklist in pull request" width="880" height="691"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And as things are checked off, the number of steps are reflected in the list of pull requests:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ops.io/images/ZuUvbL-z4oxCxYPq1KGIcaErYbC5E0oiruR22n27qC0/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzL3g2YTZ5/Z2Rnem13NHhpdjFm/enFiLnBuZw" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ops.io/images/ZuUvbL-z4oxCxYPq1KGIcaErYbC5E0oiruR22n27qC0/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzL3g2YTZ5/Z2Rnem13NHhpdjFm/enFiLnBuZw" alt="Index of pull requests, showing completed steps" width="880" height="272"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So a checklist is a simple thing, yet I can attest to how powerful and preventative it is.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Adding code style check (+ GitHub Action)</title>
      <dc:creator>Jason Purdy</dc:creator>
      <pubDate>Sun, 29 May 2022 16:29:14 +0000</pubDate>
      <link>https://community.ops.io/purdy/adding-code-style-check-github-action-3nmb</link>
      <guid>https://community.ops.io/purdy/adding-code-style-check-github-action-3nmb</guid>
      <description>&lt;p&gt;Code style dictates how you write code in order to make the code readability consistent throughout your organization. Style is opinionated and there are many different approaches. With my work, we mostly develop in Drupal, which has its own style guide, and there are other PHP style guides for Zend, PSR, etc.&lt;/p&gt;

&lt;p&gt;PHP has a &lt;a href="https://github.com/squizlabs/PHP_CodeSniffer"&gt;code sniffer&lt;/a&gt; which can run through your code looking for non-compliant code, given the style you want to comply with. It also comes with a tool (&lt;code&gt;phpcbf&lt;/code&gt;) that can automatically fix simple issues.&lt;/p&gt;

&lt;p&gt;To get started, you want to add the sniffer to your composer.json require-dev section. If you're also developing with Drupal, you'll want to add the &lt;code&gt;drupal/coder&lt;/code&gt; library, which will bring in the Drupal code style guides.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nl"&gt;"require-dev"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"drupal/coder"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"^8.3.1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"squizlabs/php_codesniffer"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"^3.4.0"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So that will get the &lt;code&gt;phpcs&lt;/code&gt; and &lt;code&gt;phpcbf&lt;/code&gt; into the &lt;code&gt;./vendor/bin&lt;/code&gt; directory and you can add a script in your composer.json that will let you run the style check through composer (&lt;code&gt;composer code-sniff&lt;/code&gt;). Here's what that section of the json looks like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nl"&gt;"scripts"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"code-sniff"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="s2"&gt;"./vendor/bin/phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,css,info,txt --ignore=node_modules,bower_components,vendor ./web/modules/custom"&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will only check the code in &lt;code&gt;./web/modules/custom&lt;/code&gt;, checking our custom code and leaving the external code alone.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ops.io/purdy/github-actions-an-easy-way-to-start-devops-l8h"&gt;I mentioned GitHub Actions before&lt;/a&gt;, but you can now add this style check to your Action, by appending a &lt;code&gt;composer install&lt;/code&gt; and &lt;code&gt;composer code-sniff&lt;/code&gt; to your steps, like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;jobs&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;build&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Code checkout and checkup&lt;/span&gt;
    &lt;span class="na"&gt;runs-on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ubuntu-latest&lt;/span&gt;
    &lt;span class="na"&gt;steps&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Checkout code&lt;/span&gt;
        &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;actions/checkout@v1&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Lint check&lt;/span&gt;
        &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;overtrue/phplint@7.4&lt;/span&gt;
        &lt;span class="na"&gt;with&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;web&lt;/span&gt;
          &lt;span class="na"&gt;options&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;--exclude=core --exclude=libraries --exclude=modules/contrib --exclude=profiles&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Composer install&lt;/span&gt;
        &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;composer install&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Check coding standards&lt;/span&gt;
        &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;composer -n code-sniff&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now this action will checkout the code, run a syntax check (excluding external code), do a composer install, and run the code-sniff command. So now with any update to GitHub, it will check for syntax errors and code style issues. The &lt;code&gt;-n&lt;/code&gt; argument to the code-sniff command is telling composer to skip any interactions, which are impossible when running through GitHub Actions.&lt;/p&gt;

</description>
      <category>drupal</category>
      <category>codestyle</category>
      <category>github</category>
    </item>
    <item>
      <title>Local git commit hooks</title>
      <dc:creator>Jason Purdy</dc:creator>
      <pubDate>Sat, 28 May 2022 21:46:01 +0000</pubDate>
      <link>https://community.ops.io/purdy/local-git-commit-hooks-2cb1</link>
      <guid>https://community.ops.io/purdy/local-git-commit-hooks-2cb1</guid>
      <description>&lt;p&gt;I mentioned in &lt;a href="https://community.ops.io/purdy/github-actions-an-easy-way-to-start-devops-l8h"&gt;a previous post&lt;/a&gt; about how GitHub can automatically check your code for syntax errors whenever you push an update to the server, but you can also catch those on your local development box before you commit code. You can just add a script in the code repo's &lt;code&gt;.git/hooks/pre-commit&lt;/code&gt; path. What we do is have our script in a &lt;code&gt;docs&lt;/code&gt; directory and then in our composer.json file, when the developer is installing/updating the php libraries, there is a script that (re)establishes the commit hook:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"post-install-cmd"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="s2"&gt;"rm -rf .git/hooks"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"ln -s ../docs/hooks .git/hooks"&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"post-update-cmd"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="s2"&gt;"rm -rf .git/hooks"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"ln -s ../docs/hooks .git/hooks"&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;As for the script itself, I cannot take credit for it. I think it originally came from &lt;a href="https://carlosbuenosvinos.com/write-your-git-hooks-in-php-and-keep-them-under-git-control/"&gt;this post&lt;/a&gt; from Carlos Buenosvinos. It doesn't look like that post is still working, but here is the script I use:&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;
This is for a Drupal project, which already has Symfony installed, so you may need to require that (and there may be other requirements), if you aren't already using that.&lt;/p&gt;

&lt;p&gt;You can see by some of the commented-out areas, I'm not doing the full verification because I just haven't had the time to work on that. I kind of want to redo it using Robo, but that's a project for another day.&lt;/p&gt;

&lt;p&gt;There are times where you want to bypass the verification. If you're in a hurry (not a good sign ;)), or if there's something wrong with the verification hook, you can skip the verification with the --no-verify argument:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git commit -m 'gotta git this code in place! ;)' --no-verify&lt;/code&gt;&lt;/p&gt;

</description>
      <category>git</category>
      <category>hooks</category>
    </item>
    <item>
      <title>GitHub Actions: An easy way to start DevOps</title>
      <dc:creator>Jason Purdy</dc:creator>
      <pubDate>Fri, 27 May 2022 12:47:23 +0000</pubDate>
      <link>https://community.ops.io/purdy/github-actions-an-easy-way-to-start-devops-l8h</link>
      <guid>https://community.ops.io/purdy/github-actions-an-easy-way-to-start-devops-l8h</guid>
      <description>&lt;p&gt;I'm barely scratching the surface, myself with DevOps and am enjoying reading other posts on this site to inspire digging deeper. If you're anything like me, though, you may find it a bit intimidating and I'd like to share one easy way to get started with DevOps. We use GitHub private repositories at work and mostly develop with PHP, so GitHub has &lt;a href="https://github.com/features/actions"&gt;&lt;em&gt;GitHub Actions&lt;/em&gt;&lt;/a&gt;, which can run anytime you push an update to GitHub.&lt;/p&gt;

&lt;p&gt;How it works is that you have a &lt;code&gt;.github/workflows&lt;/code&gt; folder and you can create one or more action files, which are in YAML format. We have a really basic one called &lt;code&gt;goodcode.yml&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Code checker (syntax)&lt;/span&gt;
&lt;span class="na"&gt;on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;push&lt;/span&gt;

&lt;span class="na"&gt;jobs&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;build&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Checkout code&lt;/span&gt;
    &lt;span class="na"&gt;runs-on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ubuntu-latest&lt;/span&gt;
    &lt;span class="na"&gt;steps&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Checkout code&lt;/span&gt;
        &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;actions/checkout@v2&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Lint check&lt;/span&gt;
        &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;overtrue/phplint@7.4&lt;/span&gt;
        &lt;span class="na"&gt;with&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;sites/all/modules/custom&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;on&lt;/code&gt; in line #2 says anytime there's a push, to run this action, which goes through the jobs and steps. The first step is checking out the code that was pushed. &lt;code&gt;actions/checkout&lt;/code&gt; is a GitHub-provided action and integrated into GitHub, so you don't need to worry about access tokens or anything like that.&lt;/p&gt;

&lt;p&gt;Then, there's a 3rd party tool called &lt;code&gt;overtrue/phplint&lt;/code&gt;, which will quickly and efficiently check your PHP files for syntax errors. Recently, I merged in some code on a new computer and unbeknownst to me, had injected the merge relics (&lt;code&gt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; HEAD&lt;/code&gt;) and when I pushed it up, it failed and emailed me, which saved me from going further in the deployment chain.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ops.io/images/07TJjnJgoRvkbNQfQIFoiJSUleYRKEm0Ys82Qc9Y5l0/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzL3c3NXE5/azdvajU3Mjl0MGth/dWVoLnBuZw" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ops.io/images/07TJjnJgoRvkbNQfQIFoiJSUleYRKEm0Ys82Qc9Y5l0/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzL3c3NXE5/azdvajU3Mjl0MGth/dWVoLnBuZw" alt="GitHub Action reports" width="786" height="351"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Starting simple is a great way to start on your DevOps path and then pick up more over time as you gain experience from others' repository setups or other posts on this site. The great thing about GitHub actions is that they're not hidden and you can peek into other repo setups if you see a &lt;code&gt;.github/workflows&lt;/code&gt; directory. I was looking for an online version of Werewolf (a great in-person social game for 6+ players with minimal setup, if you're unfamiliar) and came across &lt;a href="https://github.com/AlecM33/Werewolf"&gt;this repo&lt;/a&gt;, which is really cool! It's an express (Node.js) app and it has a &lt;code&gt;.github/workflows&lt;/code&gt; directory, which does a full-range of things, like syntax checks and unit tests.&lt;/p&gt;

&lt;p&gt;What's also neat about GitHub Actions is that it provides you with a badge code you can put into your repo's README.md, which gives a dynamic status of if your repo has recently passed its tests.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ops.io/images/w85gpKLjEqLNBxids9LYVfzSskKh2E0Qtceo8EDTu8I/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzL25yZWZ3/dDdxZDk5czViOGl3/empmLnBuZw" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ops.io/images/w85gpKLjEqLNBxids9LYVfzSskKh2E0Qtceo8EDTu8I/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzL25yZWZ3/dDdxZDk5czViOGl3/empmLnBuZw" alt="Status Badge in Werewolf repo" width="739" height="204"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>githubactions</category>
      <category>github</category>
      <category>php</category>
    </item>
    <item>
      <title>Automatic EB deployment from git push</title>
      <dc:creator>Jason Purdy</dc:creator>
      <pubDate>Fri, 27 May 2022 01:27:25 +0000</pubDate>
      <link>https://community.ops.io/purdy/automatic-eb-deployment-from-git-push-3lkf</link>
      <guid>https://community.ops.io/purdy/automatic-eb-deployment-from-git-push-3lkf</guid>
      <description>&lt;p&gt;AWS has a service called Code Pipeline, which probably has a lot of super special skilz to do amazing things, but they also have a dead-easy yet still powerful feature that will automatically deploy updates to an Elastic Beanstalk environment. What this means is that you can set it up so that it "listens" to a GitHub repository and whenever a branch has an update, it will bundle it all together with a ZIP file and then send the ZIP file to Elastic Beanstalk to go through its deployment steps. Here's how you set it up:&lt;/p&gt;

&lt;p&gt;First, you go to &lt;a href="https://us-east-1.console.aws.amazon.com/codesuite/codepipeline/pipeline/new"&gt;add a new Pipeline&lt;/a&gt;, which looks a little something like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ops.io/images/GklGGR1mt_mzzkAtgdXs07CecrOh00sFEvGZKCIQfc8/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzL2xxbHFo/ZzgwOWZ3aGd0dG4w/cTEyLnBuZw" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ops.io/images/GklGGR1mt_mzzkAtgdXs07CecrOh00sFEvGZKCIQfc8/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzL2xxbHFo/ZzgwOWZ3aGd0dG4w/cTEyLnBuZw" alt="Step 1 of creating a Code Pipeline" width="880" height="560"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After hitting next, you need to setup the Source Stage. At my work, we use GitHub and fortunately, there's a really cool integration with &lt;em&gt;GitHub (Version 2)&lt;/em&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ops.io/images/MtfCbC9X03J7HGEOC8mRDUo7WZQXy5M4-_xy6lVhx9w/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzL3A2NHVk/NmZ1Yno3NG12ZXN1/cmEwLnBuZw" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ops.io/images/MtfCbC9X03J7HGEOC8mRDUo7WZQXy5M4-_xy6lVhx9w/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzL3A2NHVk/NmZ1Yno3NG12ZXN1/cmEwLnBuZw" alt="Step 2 of creating a Code Pipeline" width="880" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once it's connected, you can select your repo and branch and then hit Next. Skip the Build Stage and then for the Deploy Stage, you can select Elastic Beanstalk and then your application and environment target:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ops.io/images/wzbwsXzw8RILNVKJJznvxXgcakr2xeSsb5doLuvNidg/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzL3lwMTJr/azM4ZzRtZXA5eHhz/dnQ4LnBuZw" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ops.io/images/wzbwsXzw8RILNVKJJznvxXgcakr2xeSsb5doLuvNidg/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzL3lwMTJr/azM4ZzRtZXA5eHhz/dnQ4LnBuZw" alt="Final step in setting up Code Pipeline" width="880" height="725"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now what's cool is that whenever I push a change up to the &lt;em&gt;main&lt;/em&gt; branch, it automatically deploys to that Elastic Beanstalk app/env, which keeps it up-to-date with our latest work.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ops.io/images/e2Ygo_cXvD3PikLeDYTlMdsbLLVc0V08ZzewMnUtnUY/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzL3NndHp1/ZzhpdWVxcjJ2OGEw/dTdvLnBuZw" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ops.io/images/e2Ygo_cXvD3PikLeDYTlMdsbLLVc0V08ZzewMnUtnUY/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzL3NndHp1/ZzhpdWVxcjJ2OGEw/dTdvLnBuZw" alt="The pipeline in effect." width="880" height="739"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There are other repository options like Bitbucket or AWS's own Code Repository, if you have your code elsewhere.&lt;/p&gt;

&lt;p&gt;In addition, I would turn on the notifications in Elastic Beanstalk so that it emails you whenever a deployment happens (or if there's a failure). This will give you confidence in that it's actually working as well as you'll know if something broke. You set this up with your environment configuration in the Notifications section:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ops.io/images/BgxA-G84ANjrgblCG3auyOmMjAs6RCnEdO0fwsqOl-w/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzL3Btb3Rk/eWQ5ajdjZGR3djVj/Z2NlLnBuZw" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ops.io/images/BgxA-G84ANjrgblCG3auyOmMjAs6RCnEdO0fwsqOl-w/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzL3Btb3Rk/eWQ5ajdjZGR3djVj/Z2NlLnBuZw" alt="Notifications settings for Elastic Beanstalk" width="880" height="268"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>codepipeline</category>
      <category>elasticbeanstalk</category>
    </item>
    <item>
      <title>How Elastic Beanstalk stages your code</title>
      <dc:creator>Jason Purdy</dc:creator>
      <pubDate>Wed, 25 May 2022 22:45:49 +0000</pubDate>
      <link>https://community.ops.io/purdy/how-elastic-beanstalk-stages-your-code-g7o</link>
      <guid>https://community.ops.io/purdy/how-elastic-beanstalk-stages-your-code-g7o</guid>
      <description>&lt;p&gt;Maybe it's the benefit of writing an app with over a gig of data to put in place and process when building, but I have been able to piece together something that hopefully someone else finds helpful. When you deploy your latest code, it gets extracted to &lt;code&gt;/var/app/staging&lt;/code&gt; and then all of your &lt;code&gt;.ebextensions&lt;/code&gt; commands run on that directory and when it's done, it moves it to &lt;code&gt;/var/app/current&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;So why is this important? Well, as you start to add your own .ebextensions setup scripts, you have to keep your paths relative to the app. The gig of data I was talking about was a zip file of some image files necessary for the app. The zip file was downloaded to the &lt;code&gt;/tmp&lt;/code&gt; directory and then I was running &lt;code&gt;unzip /tmp/file.zip /var/app/current/path/to/images&lt;/code&gt;. This would work, but it was unzipping the image files into the current app vs. what's about to be deployed. So after the deployment was done, the &lt;code&gt;/var/app/staging/path/to/images&lt;/code&gt; was empty and then became &lt;code&gt;/var/app/current/path/to/images&lt;/code&gt;. Then I was left wondering where my images were! So when you run commands that affect the filesystem, specify the paths relative to your project or app root. So that means it would look something like this: &lt;code&gt;unzip /tmp/file.zip path/to/images&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;I should also mention that if you have directories that are setup in particular ways, like permissions or ownership, you'll need to do that relative to the project or app root as well. We have a folder that we put uploaded files in from the public, so that needs to be owned by the webapp and world-writable. So those folders need to be handled the same way from your .ebextensions folder and relatively from the project root like so: &lt;code&gt;chmod -R a+rw path/to/uploads&lt;/code&gt;.&lt;/p&gt;

</description>
      <category>aws</category>
      <category>elasticbeanstalk</category>
    </item>
  </channel>
</rss>
