Centralized CI repository for The0mikkel.
Allows for easy management of CI pipelines, in regards to updates and new features.
The project uses Semantic versioning, and the version is determined using Semantic release.
You can use the version of the release, to lock in the version of the action that you want to use.
You may also use the sha, to lock version more securely
Please only use main as the version, if you want to use the latest version, as it may be unstable or updated in a way that breaks your workflow.
This action will run Semantic Release to determine the next version of the package and create a new release.
Semver release pipeline can be used with or without (standalone) a node project in the root of the project.
Node project setup
Initialize a project with npm:
npm init -yThe following packages need to be installed:
npm install --save-dev @semantic-release/commit-analyzer @semantic-release/git @semantic-release/github @semantic-release/npm @semantic-release/release-notes-generator conventional-changelog-conventionalcommitsThe following configuration needs to be added to a new file .releaserc.json:
{
"branches": [
"main",
{
"name": "develop",
"prerelease": "r"
}
],
"plugins": [
[
"@semantic-release/commit-analyzer",
{
"preset": "conventionalcommits"
}
],
[
"@semantic-release/release-notes-generator",
{
"preset": "conventionalcommits"
}
],
[
"@semantic-release/github",
{
"successComment": false
}
],
[
"@semantic-release/npm",
{
"npmPublish": false
}
],
"@semantic-release/git"
]
}This file is the default configuration and can be changed to fit the needs of the project.
A .gitignore file should be added to the repository to ignore the node_modules folder, created by NPM.
node_modulesStandalone
The following configuration needs to be added to a new file .releaserc.json:
{
"branches": [
"main",
{
"name": "develop",
"prerelease": "r"
}
],
"plugins": [
[
"@semantic-release/commit-analyzer",
{
"preset": "conventionalcommits"
}
],
[
"@semantic-release/release-notes-generator",
{
"preset": "conventionalcommits"
}
],
[
"@semantic-release/github",
{
"successComment": false
}
],
[
"@semantic-release/exec",
{
"prepareCmd": "echo ${nextRelease.version} > version.txt",
"publishCmd": "echo 'Published version ${nextRelease.version}'"
}
],
[
"@semantic-release/git",
{
"assets": ["version.txt"],
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}
]
]
}It may be configured to your liking, according to the configuration file format.
If not included in the repository, this file will be used.
GH_TOKEN: The GitHub token to use for authentication. Defaults to the default GitHub token.ENVIRONMENT: The environment to deploy to. Defaults to an empty string.
version: The version that was released. This may be null if no release was created.
Usage of the action:
release:
name: Release
uses: the0mikkel/ci/.github/workflows/[email protected]Standalone version:
release:
name: Release
uses: the0mikkel/ci/.github/workflows/[email protected]This action will build a Docker image and push it to the GitHub Container Registry.
Currently, it will push to the same image name as the repository name, but allows for specifying the tags.
It by defaults sets tags for latest, sha and version numbers.
The action requires a Dockerfile to be present in the repository.
Where it is located can be specified in the action.
dockerfile: The path to the Dockerfile. Defaults to./Dockerfile.context: The build context for the Docker build. Defaults to..args: Build arguments to pass to the Docker build. Defaults to an empty string.
Example:VERSION=1.0.0semver: The version to tag the image with. Leave empty, if you don't want to tag the image with the version. Defaults to an empty string.
Example:1.0.0or${{ steps.release.outputs.version }}tags: Additional tags to add to the image. Defaults totype=raw,value=${{ github.sha }}registry: What registry to use. Defaults to GitHub container registryghcr.ioimage_name: Name of image. Defaults to GitHub repository${{ github.repository }}registry_username: Username to use for registry login. Defaults to Github actor.registry_token: Token to use for registry login. Defaults to GITHUB_TOKEN.platforms: Platforms to build for (comma separated, e.g., linux/amd64,linux/arm64). Defaults tolinux/amd64.runner: Runner to use for the job. Defaults toubuntu-latest.commit: Commit SHA to use for git operations and tagging. Defaults to github.sha.
Usage of the action:
docker:
name: Docker
needs:
- release
uses: the0mikkel/ci/.github/workflows/[email protected]
with:
semver: ${{ needs.release.outputs.version }}This action checks if the PR title fits the Conventional commits format.
Perfect for ensuring the PR fits the Conventional commits format for Semantic release.
This action requires no specific setup in the repository.
There are not inputs for this action.
Usage of the action:
name: PR format test - Conventional commits
on:
pull_request:
types: [opened, synchronize, edited, reopened]
jobs:
pr-linter:
name: Pull Request title check
uses: the0mikkel/ci/.github/workflows/[email protected]