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 GitHub Actions, which can run anytime you push an update to GitHub.
How it works is that you have a .github/workflows
folder and you can create one or more action files, which are in YAML format. We have a really basic one called goodcode.yml
:
name: Code checker (syntax)
on: push
jobs:
build:
name: Checkout code
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Lint check
uses: overtrue/phplint@7.4
with:
path: sites/all/modules/custom
The on
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. actions/checkout
is a GitHub-provided action and integrated into GitHub, so you don't need to worry about access tokens or anything like that.
Then, there's a 3rd party tool called overtrue/phplint
, 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 (<<<<<<< HEAD
) and when I pushed it up, it failed and emailed me, which saved me from going further in the deployment chain.
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 .github/workflows
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 this repo, which is really cool! It's an express (Node.js) app and it has a .github/workflows
directory, which does a full-range of things, like syntax checks and unit tests.
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.
Top comments (0)