Posts tagged: actions

All posts with the tag "actions"

8 posts latest post 2022-12-07
Publishing rhythm
Dec 2022 | 1 posts
Give github actions the -e flag in the shebang #! so they fail on any one command failure. Otherwise each line will set the exit status, but only the last one will be passed to ci. #!/bin/bash -e What is -e # [1] The -e flag to the bash command allows your script to exit immediately if any command within the script returns a non-zero exit status. This can be useful for ensuring that your script exits with an error if any of the commands it runs fail, which can help you identify and debug issues in your script. For example, if you have a script that runs several commands and one of those commands fails, the script will continue running without the -e flag, but will exit immediately if the -e flag is present. This can make it easier to troubleshoot your script and ensure that it runs correctly. Solution for Windows # [2] In windows the solution is not quite as simple. You can define a function in a Windows batch script that wraps an if statement to check the exit status of a command and handle any errors that may have occurred. Here is an example of how you might define a function called “check_error” that does this: :check_error if errorlevel 1 ( echo An error occurred! ex...

Site Down During Build

Recently I noticed a new netlify site of mine was down while I was checking to see if new content was live. Later found out this was consistent after each and every push the site would go gown as soon as I hit push, and would not come back until the build finished. Is this normal? # [1] Do other Netlify sites go down during build??? Short Answer NO. All of my google fu lead me to believe I was alone and none of my other sites do this. Digging into my build # [2] My deploy script ends with the following. After resetting keys and watching it build half a dozen times I determined that everything was working as normal here. - name: Deploy to Netlify uses: nwtgck/[email protected] with: publish-dir: "./markout" production-branch: markout production-deploy: true deploy-message: "Deploy markout from GitHub Actions" env: NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} Opening the Nelify Console # [3] After poking at t...

Review of the git-auto-commit-action

It’s a really cool GitHub action that will automatically commit files changed during the action. I was using this to render a new readme based on a template. Check out the repo for git-auto-commit-action [1]. It’s a really cool GitHub action that will automatically commit files changed during the action. I was using this to render a new readme based on a template. This has been by far the easiest way to commit back to a repo that I have seen. Other patterns often require fully setting up the git [2] user and everything. While it’s not all that hard, this action already has all of that covered. You must give it a commit message and thats it. Optionally you can configure a number of things. Its possible to configure the commit_user_name, commit_user_email, and commit_author. I often also scope the file_pattern to a certain subset of files. --- [3] If you’re new to actions check out this article on using actions. [3] If you’re new to actions check out this article on using a...

Four github actions for your website

GitHub’s actions are a new GitHub feature that will trigger GitHub to spin up a virtual machine and run some tasks with some special access to your repo. It can interact with comments/issues, it can clone your repo, You can explicitly pass in secrets so that it can commit back to the repo or deploy to another service. The environment may be a Linux, windows, or even a mac machine. I believe this is wildly incredible for the open-source community, putting these tools in the same place that we are already collaborating is so convenient. What can they do for my personal website? 🤔 # [1] GitHub actions can give you confidence that your site is up and running, with the latest JavaScript packages, does not have broken links, and can even take screenshots of what your website looks like on different screen sizes and operating systems. - periodically check that the website is up - update npm - url checker - screenshot website srt32/uptime [2] # [3] srt32/uptime [2] is an action that...

Four Github Actions for Python

If you are developing python packages and using GitHub here are four actions that you can use today to automate your release workflow. Since python tools generally have such a simple cli I have opted to use the cli for most of these, that way I know exactly what is happening and have more control over it if I need. h2 img { width: 100%; box-shadow: .5rem .5rem 3rem #141F2D, -.5rem -.5rem 3rem rgba(255,255,255,.1);} img{ max-width: 100% !important;} If you are developing python packages and using GitHub here are four actions that you can use today to automate your release workflow. Since python tools generally have such a simple cli I have opted to use the cli for most of these, that way I know exactly what is happening and have more control over it if I need. - Lint - Test - Package - Upload to PyPi Lint With flake8 # [1] flake8 is pythons quintessential linting tool to ensure that your code is up to the standards that you have set for the project, and to help prevent hidden...

Send Emails with GitHub Actions

Here is one useful thing that you can do with GitHub actions no matter what language you use, send email. You might want to know right away when your ci passes. You might want to give your team a nice pat on the back when a new release is deployed. There might be subscribers wanting to see the latest release notes in their inbox as soon as the latest version is deployed. Whatever it is, its pretty easy to do with an action right out of the actions marketplace. Mail on Star # [1] Here is a silly example that sends an email to yourself anytime someone stars your repo. name: Mail on Star on: watch: types: [ started ] # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: # This workflow contains a single job called "email" email: # The type of runner that the job will run on runs-on: ubuntu-latest # Steps represent a sequence of tasks that will be executed as part of the job steps: - name: ✨ Send email, you star uses: dawidd6/acti...

What Are GitHub Actions

GitHub actions are an amazing tool that allows us to run code based on triggers inside of our repo. Their is a large and growing community of actions inside the marketplace to use with very little effort. Best of all they are free for public repositories, and private repos have a very generous free tier. h2 img { width: 100%; box-shadow: .5rem .5rem 3rem #141F2D, -.5rem -.5rem 3rem rgba(255,255,255,.1);} img{ max-width: 100% !important;} I have been diving deep into Github actions for about a month now and they are wicked good! They allow you to run any sort of arbitrary code based on events in your repo, webhooks, or schedules. They are very reasonably priced. The interface that GitHub hs developed for them is top-notch! It’s so good I have done 90% of my editing of them right from github.com. TLDR # [1] some interaction to your repository triggers code to run. [2] # [3] The online editor for actions is pretty amazing. When creating a new workflow it automatically sets up a ...

Getting Started with GitHub Actions

Github actions are written in configuration files using the YAML syntax. YAML is a superset of JSON. Most YAML can be expressed inline with JSON syntax. Similar to python YAML is whitespace driven by whitespace rather than brackets tags. The argument for using YAML for configuration files such as actions is that it is more human-readable and editable. It’s much easier to see the whitespace layout than it is to get closing brackets correct. For actions, I believe this is mostly true. I don’t see any use case to get past 3-5 indents, which is completely manageable. Can I just say that I learned more than I realized about YAML by writing this article Arrays and Objects # [1] In YAML or JSON, the most basic containers for data are arrays, a 1D list of things, and objects, for key-value pairs. Arrays # [2] The start of an array container is signified with a leading -. This is probably one of the big things I didn’t understand about YAML before writing this post, but hats off to the ...