Skip to content

Commit

Permalink
ci: add docker workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
fredleger committed Jan 3, 2025
1 parent d333d69 commit f0c4eb9
Show file tree
Hide file tree
Showing 8 changed files with 340 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# These are supported funding model platforms

github:
- fredleger
patreon: webofmars
34 changes: 34 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# .github/dependabot.yml
version: 2
updates:

- package-ecosystem: "github-actions"
directories:
- "/"
open-pull-requests-limit: 3
labels:
- "github_actions"
schedule:
interval: "weekly"
day: friday
time: '04:00'

- package-ecosystem: "docker"
directory: "/"
open-pull-requests-limit: 3
labels:
- "docker"
schedule:
interval: "weekly"
day: friday
time: '04:10'

- package-ecosystem: "gomod"
directory: "/"
open-pull-requests-limit: 3
labels:
- "pip"
schedule:
interval: "weekly"
day: friday
time: '04:20'
169 changes: 169 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
template: |
## What's Changed
$CHANGES
## Full Changelog
- https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...$RESOLVED_VERSION
name-template: "Version $RESOLVED_VERSION"
tag-template: "$RESOLVED_VERSION"

version-resolver:
major:
labels:
- "release-major"
minor:
labels:
- "release-minor"
patch:
labels:
- "release-patch"
default: patch

categories:
- title: '🚀 Features'
labels:
- 'feature'
- 'feat'
- title: '🐛 Bug Fixes'
labels:
- 'fix'
- 'bugfix'
- 'bug'
- title: '🧰 Maintenance'
label: 'chore'
- title: '📚 Documentation'
label: 'docs'
- title: '🧪 Tests'
label: 'test'
- title: '🏷️ Version Tags'
label: 'version'
- title: '🔖 Release Tags'
label: 'release'
- title: '🧩 Dependencies'
label: 'dependencies'
- title: '🔒 Security'
label: 'security'
- title: '🚨 Breaking Changes'
label: 'breaking'
- title: '🧹 Code Cleanup'
label: 'cleanup'
- title: '🔧 Config'
label: 'config'
- title: '📦 Packages'
label: 'package'
- title: '🔥 Removals'
label: 'removal'
- title: '🚧 Work In Progress'
label: 'wip'
- title: '🔀 Merges'
label: 'merge'
- title: '🎨 Style'
label: 'style'
- title: '🔊 Logging'
label: 'logging'
- title: '🔇 Silence'
label: 'silence'
- title: '🤖 CI/CD'
label: 'ci'

autolabeler:
- label: "release-major"
title:
- "/^BREAKING CHANGE:/"
- label: "release-minor"
title:
- "/^feat:/"
- "/^feat\\(.+\\):/"
- label: "feature"
title:
- "/^feat:/"
- "/^feat\\(.+\\):/"
- label: "fix"
title:
- "/^fix:/"
- "/^fix\\(.+\\):/"
- label: "ci"
title:
- "/^ci:/"
- "/^ci\\(.+\\):/"
- label: "chore"
title:
- "/^chore:/"
- "/^chore\\(.+\\):/"
- label: "docs"
title:
- "/^docs:/"
- "/^docs\\(.+\\):/"
- "/^doc:/"
- "/^doc\\(.+\\):/"
- label: "test"
title:
- "/^test:/"
- "/^test\\(.+\\):/"
- label: "version"
title:
- "/^version:/"
- "/^version\\(.+\\):/"
- label: "release"
title:
- "/^release:/"
- "/^release\\(.+\\):/"
- label: "dependencies"
title:
- "/^deps:/"
- "/^deps\\(.+\\):/"
- "/^dependencies:/"
- "/^dependencies\\(.+\\):/"
- label: "security"
title:
- "/^security:/"
- "/^security\\(.+\\):/"
- label: "breaking"
title:
- "/^breaking:/"
- "/^breaking\\(.+\\):/"
- "/^BREAKING CHANGE:/"
- label: "cleanup"
title:
- "/^cleanup:/"
- "/^cleanup\\(.+\\):/"
- "/^refactor:/"
- "/^refactor\\(.+\\):/"
- label: "config"
title:
- "/^config:/"
- "/^config\\(.+\\):/"
- label: "package"
title:
- "/^package:/"
- "/^package\\(.+\\):/"
- label: "removal"
title:
- "/^removal:/"
- "/^removal\\(.+\\):/"
- "/^remove:/"
- "/^remove\\(.+\\):/"
- label: "wip"
title:
- "/^wip:/"
- "/^wip\\(.+\\):/"
- label: "merge"
title:
- "/^merge:/"
- "/^merge\\(.+\\):/"
- label: "style"
title:
- "/^style:/"
- "/^style\\(.+\\):/"
- label: "logging"
title:
- "/^logging:/"
- "/^logging\\(.+\\):/"
- "/^log:/"
- "/^log\\(.+\\):/"
- label: "silence"
title:
- "/^silence:/"
- "/^silence\\(.+\\):/"
21 changes: 21 additions & 0 deletions .github/workflows/clean-docker-tags.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Prune pull requests images tags

on:
workflow_dispatch:
push:
branches: [main]

permissions:
contents: read
pull-requests: read
packages: write
id-token: write

jobs:
main:
uses: hoverkraft-tech/ci-github-container/.github/workflows/[email protected]
with:
runs-on: '["ubuntu-24.04"]'
images: "mailrelay"
prune-cache-images: true
pull-request-tag-filter: "^pr-([0-9]+)(?:-|$)"
43 changes: 43 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Docker build images

on:
push:
branches:
- main
pull_request:
branches: [main]
merge_group:
workflow_call:
inputs:
tag:
description: "Tag Version (semver - x.x.x)"
type: string
required: false
outputs:
built-images:
value: ${{ jobs.docker-build-images.outputs.built-images }}

permissions:
contents: read
issues: read
packages: write
pull-requests: read
id-token: write

jobs:
docker-build-images:
uses: hoverkraft-tech/ci-github-container/.github/workflows/[email protected]
secrets:
oci-registry-password: ${{ secrets.GITHUB_TOKEN }}
with:
runs-on: '["ubuntu-24.04"]'
images: |
[{
"name": "mailrelay",
"dockerfile": "./Dockerfile",
"build-args": {},
"platforms": [
"linux/amd64",
"linux/arm64"
]
}]
16 changes: 10 additions & 6 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,27 @@ name: Go
on:
push:
branches:
- master
- main
pull_request:

jobs:

build:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.20'
go-version: '1.23'

- name: Build
run: go build -v ./...
run: |
cd $GITHUB_WORKSPACE/src
go build -v ./...
- name: Test
run: go test -v ./...
run: |
cd $GITHUB_WORKSPACE/src
go test -v ./...
56 changes: 56 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: 🚀 Release

on:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:

check-branches:
name: Check branches
runs-on: self-hosted
steps:
- name: Check branch
run: |
if [[ "${{ github.ref_name }}" != "${{ github.event.repository.default_branch }}" ]]; then
echo "This action can only be run on the ${{ github.event.repository.default_branch }} branch"
exit 1
fi
update_release_draft:
name: Draft a new release
# we want to publish a new tag only if ci succeeds
needs: check-branches
permissions:
contents: write
pull-requests: write
runs-on: self-hosted
outputs:
latestRelease: ${{ steps.update_release_draft.outputs.tag_name }}
steps:
# create a new release
- id: update_release_draft
uses: release-drafter/release-drafter@v6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
publish: true
disable-autolabeler: true

ci:
needs: update_release_draft
name: Continuous Integration
uses: ./.github/workflows/docker.yml
with:
tag: ${{ needs.update_release_draft.outputs.latestRelease }}
permissions:
actions: write
contents: read
id-token: write
issues: read
packages: write
pull-requests: read
secrets: inherit
2 changes: 2 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

cd src

# build Linux
echo building Linux...
env GOOS=linux GOARCH=amd64 go build -o ./build/linux_amd64/mailrelay-linux-amd64
Expand Down

0 comments on commit f0c4eb9

Please sign in to comment.