This repository acts as a fallback for all repositories under my crazy-max
handle that don't have an actual .github
directory with issue templates and
other community health files.
It also contains a collection of GitHub Actions and reusable workflows that can be used in your own repositories.
container-logs-check
composite action
checks for a string in container logs. This can be used as a poor man's e2e
testing for containers.
name: test
on:
push:
jobs:
test:
runs-on: ubuntu-latest
steps:
-
name: Run container
run: |
docker run -d --name test crazymax/samba:4.18.2
-
name: Check container logs
uses: crazy-max/.github/.github/actions/container-logs-check@main
with:
container_name: test
log_check: " started."
timeout: 20
Action logs:
Setting timezone to UTC
Initializing files and folders
Setting global configuration
Creating user foo/foo (1000:1000)
Added user foo.
Creating user yyy/xxx (1100:1200)
Added user yyy.
Add global option: force user = foo
Add global option: force group = foo
Creating share public
Creating share share
Creating share foo
# Global parameters
[global]
disable netbios = Yes
...
strict locking = No
vfs objects = fruit streams_xattr
wide links = Yes
smbd version 4.18.2 started.
🎉 Found " started." in container logs
gotest-annotations
composite action
generates GitHub annotations for generated Go JSON test reports.
name: ci
on:
push:
jobs:
go:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Test
run: |
mkdir -p ./testreports
go test -coverprofile ./testreports/cover.out -json ./... > ./testreports/test-report.json
-
name: Generate annotations
uses: crazy-max/.github/.github/actions/gotest-annotations@main
with:
directory: ./testreports
install-k3s
composite action
installs k3s on a runner.
name: ci
on:
push:
jobs:
install-k3s:
# does not work with ubuntu-22.04 atm:
# E0310 17:16:57.210215 2047 memcache.go:238] couldn't get current server API group list: Get "https://127.0.0.1:6443/api?timeout=32s": dial tcp 127.0.0.1:6443: connect: connection refused
runs-on: ubuntu-20.04
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Install k3s
uses: crazy-max/.github/.github/actions/install-k3s@main
with:
version: v1.21.2-k3s1
list-commits
reusable workflow
generates a JSON matrix with the list of commits for a pull request.
name: ci
on:
push:
pull_request:
jobs:
list-commits:
uses: crazy-max/.github/.github/workflows/list-commits.yml@main
with:
limit: 10
secrets: inherit
validate:
runs-on: ubuntu-latest
needs:
- list-commits
strategy:
fail-fast: false
matrix:
commit: ${{ fromJson(needs.list-commits.outputs.matrix) }}
steps:
-
name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ matrix.commit }}
Note
limit
input is optional and defaults to0
(unlimited).
releases-json
reusable workflow
generates a JSON file with the list of releases for a given repository.
name: ci
on:
push:
jobs:
releases-json:
uses: crazy-max/.github/.github/workflows/releases-json.yml@main
with:
repository: docker/buildx
artifact_name: buildx-releases-json
filename: buildx-releases.json
secrets: inherit
releases-json-check:
runs-on: ubuntu-latest
needs:
- releases-json
steps:
-
name: Download
uses: actions/download-artifact@v4
with:
name: buildx-releases-json
path: .
-
name: Check file
run: |
jq . buildx-releases.json
Typical usage is to generate and put this file on your repository if you don't want to use the GitHub API to get the list of releases and therefore avoid hitting the rate limit (see docker/buildx#1563 for more info).
For example on crazy-max/ghaction-hugo repo, I use this workflow to generate a JSON file with the list of Hugo releases and then use it in the action to check for latest and tagged releases:
async function getRelease(version) {
const url = `https://raw.githubusercontent.com/crazy-max/ghaction-hugo/master/.github/hugo-releases.json`;
const response = await fetch(url);
const releases = await response.json();
console.log(JSON.stringify(releases[version], null, 2));
}
getRelease('latest');
{
"id": 89231061,
"tag_name": "v0.110.0",
"html_url": "https://github.com/gohugoio/hugo/releases/tag/v0.110.0",
"assets": [
"https://github.com/gohugoio/hugo/releases/download/v0.110.0/hugo_0.110.0_checksums.txt",
"https://github.com/gohugoio/hugo/releases/download/v0.110.0/hugo_0.110.0_darwin-universal.tar.gz",
"https://github.com/gohugoio/hugo/releases/download/v0.110.0/hugo_0.110.0_dragonfly-amd64.tar.gz",
"https://github.com/gohugoio/hugo/releases/download/v0.110.0/hugo_0.110.0_freebsd-amd64.tar.gz",
"https://github.com/gohugoio/hugo/releases/download/v0.110.0/hugo_0.110.0_Linux-64bit.tar.gz",
"https://github.com/gohugoio/hugo/releases/download/v0.110.0/hugo_0.110.0_linux-amd64.deb",
"https://github.com/gohugoio/hugo/releases/download/v0.110.0/hugo_0.110.0_linux-amd64.tar.gz",
"https://github.com/gohugoio/hugo/releases/download/v0.110.0/hugo_0.110.0_linux-arm.tar.gz",
"https://github.com/gohugoio/hugo/releases/download/v0.110.0/hugo_0.110.0_linux-arm64.deb",
"https://github.com/gohugoio/hugo/releases/download/v0.110.0/hugo_0.110.0_linux-arm64.tar.gz",
"https://github.com/gohugoio/hugo/releases/download/v0.110.0/hugo_0.110.0_netbsd-amd64.tar.gz",
"https://github.com/gohugoio/hugo/releases/download/v0.110.0/hugo_0.110.0_openbsd-amd64.tar.gz",
"https://github.com/gohugoio/hugo/releases/download/v0.110.0/hugo_0.110.0_windows-amd64.zip",
"https://github.com/gohugoio/hugo/releases/download/v0.110.0/hugo_0.110.0_windows-arm64.zip",
"https://github.com/gohugoio/hugo/releases/download/v0.110.0/hugo_extended_0.110.0_darwin-universal.tar.gz",
"https://github.com/gohugoio/hugo/releases/download/v0.110.0/hugo_extended_0.110.0_Linux-64bit.tar.gz",
"https://github.com/gohugoio/hugo/releases/download/v0.110.0/hugo_extended_0.110.0_linux-amd64.deb",
"https://github.com/gohugoio/hugo/releases/download/v0.110.0/hugo_extended_0.110.0_linux-amd64.tar.gz",
"https://github.com/gohugoio/hugo/releases/download/v0.110.0/hugo_extended_0.110.0_linux-arm64.deb",
"https://github.com/gohugoio/hugo/releases/download/v0.110.0/hugo_extended_0.110.0_linux-arm64.tar.gz",
"https://github.com/gohugoio/hugo/releases/download/v0.110.0/hugo_extended_0.110.0_windows-amd64.zip"
]
}
This workflow runs on push and schedule event, generates the JSON file and opens a pull request if it contains new releases, so it's kept in sync with https://github.com/gohugoio/hugo.