To access the environment variable in a Docker container action, you must pass the input using the args keyword in the action metadata file. For more information about the action metadata file for Docker container actions, see "Creating a Docker container action."
Optional Output parameters allow you to declare data that an action sets. Actions that run later in a workflow can use the output data set in previously run actions. For example, if you had an action that performed the addition of two inputs (x + y = z), the action could output the sum (z) for other actions to use as an input.
My next thought was that my organization disabled actions, so I followed the steps on this GitHub documentation page about managing actions for your organization. But again, I go to Your organizations -> Settings and look for "Actions" in the left sidebar, and it's nowhere to be found.
Workflows are constructed from a series of tasks or actions, which each represent an individual Docker container. For example, to create and publish a Docker container, my workflow consists of 5 actions:
Each of these actions are performed in their own container (most using Docker-in-Docker) and have individual logs. The visual editor makes this quite clear, when providing parameters you can only supply:
Since actions are just containers, all you need to do is supply a Docker container, and GitHub can run it a part of a workflow to do whatever you want it to do. There are several custom labels that GitHub wants from your Dockerfile, but otherwise it's fairly straightforward:
This is an example from a test one that I put together. I haven't found a full list of icon names or color names and have had to scrounge around and look at existing implementations to find possible values.
I believe you can also use a container defined within the current repository - I've seen the option for it in the UI, but haven't tried it yet. When this option did show up in the UI, it had the correct colour and icon, too.
Unfortunately, the consistency is extremely eventual. Immediately after creating your first workflow definition, the Actions tab will still say "hey you have no actions why not try creating one" for a good couple minutes. Similarly, when an Action starts, the tab says "hey there was a problem starting this workflow, your definition might be invalid" until the action actually kicks off.
Another issue is the lack of clear documentation. I've had to look into the implementations of several containers to figure out which arguments I need to provide, and I cannot find any documentation for some things like what icons are available for custom definitions.
Pay attention, $INPUT_BUILD_MODE is equal to inputs.build_mode in actions.yml file and the same logic also applies to $INPUT_ARGS (inputs.args). In other words, all variables, that you would allow for definition to your users should be defined as $INPUT_.
With this workflow in place, whenever there is a pull request or a push to the main branch, GitHub Actions will automatically build and push the multi-architecture container image for both amd64 and arm64 architectures. You can expand on this workflow by adding additional steps for testing, deploying, or other actions as per your project requirements.
An Amazon CodeCatalyst workflow is an automated procedure that describes how to build, test, and deploy your code as part of a continuous integration and continuous delivery (CI/CD) system. You can use GitHub Actions alongside native CodeCatalyst actions in a CodeCatalyst workflow.
Notice that the actions are configured to run in parallel. In the previous post, when I discussed the deployment workflow, the steps were sequential. This made sense since each step built on the previous step. For the pull request workflow, the actions are independent, and I will allow them to run in parallel so they complete faster. I select Validate, and assuming there are no issues, I select Commit to save my changes to the repository.
With Super-Linter working, I turn my attention to creating a Software Bill of Materials (SBOM). I am going to use OWASP CycloneDX to create the SBOM. Not only is there a curated list of actions that many developers may find helpful, but you can use almost any GitHub Action in CodeCatalyst. To add a GitHub Action that is not in the curated list, I return to edit mode, find GitHub Actions in the list of curated actions, and click the plus icon to add it to the workflow.
CodeCatalyst will add a new action to the workflow and open the configuration dialog box. I choose the Configuration tab and use the pencil icon to change the Action Name to Software-Bill-of-Materials. Then, I scroll down to the configuration section, and change the GitHub Action YAML. Note that you can copy the YAML from the GitHub Actions Marketplace, including the latest version number. In addition, the CycloneDX action expects you to pass the path to the Python requirements file as an input parameter.
Since I am using the generic GitHub Action, I must tell CodeCatalyst which artifacts are produced by the action and should be collected after execution. CycloneDX creates an XML file called bom.xml which I configure as an artifact. Note that a CodeCatalyst artifact is the output of a workflow action, and typically consists of a folder or archive of files. You can share artifacts with subsequent actions.
Once again, I select Validate, and assuming there are no issues, I select Commit to save my changes to the repository. I now have three actions that run in parallel when a pull request is submitted: CodeGuru, Super-Linter, and Software Bill of Materials.
The workflow is now enforcing code quality and generating a SBOM like I wanted. Note that while this is a great start, there is still room for improvement. First, I could collect reports generated by the actions in my workflow, and define success criteria for code quality. Second, I could scan the SBOM for known security vulnerabilities using a Software Composition Analysis (SCA) solution. I will be covering this in a future post in this series.
In this post, you learned how to add GitHub Actions to a CodeCatalyst workflow. I used GitHub Actions alongside native CodeCatalyst actions in my workflow. I also discussed adding actions from both the curated list of actions and others not in the curated list. Read the documentation to learn more about using GitHub Actions in CodeCatalyst.
Learn how to create a .NET app that can be used as a GitHub Action. GitHub Actions enable workflow automation and composition. With GitHub Actions, you can build, test, and deploy source code from GitHub. Additionally, actions expose the ability to programmatically interact with issues, create pull requests, perform code reviews, and manage branches. For more information on continuous integration with GitHub Actions, see Building and testing .NET.
External project or package references can be used, and registered with dependency injection. The Get is a static local function, which requires the IHost instance, and is used to resolve required services. With the CommandLine.Parser.Default singleton, the app gets a parser instance from the args. When the arguments are unable to be parsed, the app exits with a non-zero exit code. For more information, see Setting exit codes for actions.
With the .NET app containerized, and the action inputs and outputs defined, you're ready to consume the action. GitHub Actions are not required to be published in the GitHub Marketplace to be used. Workflows are defined in the .github/workflows directory of a repository as YAML files.
actions-toolkit is a wrapper around some fantastic open source libraries, and provides some helper methods for dealing with GitHub Actions. It uses some of the above libraries, and bases its paradigms on our experience building and using Probot. Check out the repo for the full API documentation.
GitHub recently announced general availability of its managed CI/CD platform, GitHub Actions. There is much to be excited about with this announcement, given the deep integration it offers with the rest of the GitHub platform. GitHub Actions allows you to automate all the tasks involved with software delivery. However, beyond all the goodness of GitHub Actions, there was one part of the developer experience that was extremely painful. The only way to test your workflows and actions was through the commit/push/pray method ?. This results in not only a painful feedback loop but also a noisy commit history:
This approach worked surprisingly well. Each job would consist of a long running container in which each step would be a new exec command in the job container. Additionally, for steps that used custom actions, act would then download the action repo and run it in a separate container, using the volumes from the job container to emulate the behavior of a self-hosted runner.
Everything was going great until I started testing some sample GitHub Actions. Many of the actions assumed the installation of various tools such as NodeJS, Python, Golang, or GCC. Building the Dockerfile to create an image with all these tools seemed impossible to do once, let alone keep updated. Fortunately, GitHub open sourced the Packer files used to define the Azure VM Images for self-hosted runners. I was able to convert these Packer files to use the Docker builder rather than the Azure ARM builder in the nektos/act-environments repo. Good news, I now had a Docker image that mirrored the Azure VM Image!
The following is a demo of running act against the cplee/github-actions-demo repository. Notice how act runs a series of Docker containers to represent the various steps of the workflow.
This open source icon is named "githubactions" and is licensed under the open source CC0 license. It's available to be downloaded in SVG and PNG formats (available in 256, 512, 1024 and 2048 PNG sizes).
It's part of the icon set "Simple Icons", which has 1,461 icons in it.
This graphic is also a logo. It's useful if you want to show the logo (for branding purposes) on your website or app.
If you need this icon available in another format, it should be pretty straight forward to download it as an SVG image file, and then import it into apps like Crello, Photoshop, RelayThat or Visme. Converting it to an ICO, JPEG or WebP image format or file type should also be pretty simple (we hope to add that feature to Iconduck soon).