-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(ci): add new ci jobs for docker builds & changelogs (#19)
- Loading branch information
Showing
11 changed files
with
320 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
* | ||
!main.go | ||
!go.mod |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: Detect Changes | ||
|
||
# todo change branch main | ||
on: | ||
push: | ||
branches: | ||
- "main" | ||
|
||
jobs: | ||
|
||
detect-changes: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
|
||
- | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
# https://github.com/tj-actions/changed-files/blob/main/README.md#inputs | ||
- | ||
name: Detect Changes | ||
uses: tj-actions/changed-files@v32.1.0 | ||
id: changes | ||
with: | ||
files: | | ||
*.go | ||
*.mod | ||
*Dockerfile | ||
# Makefile | ||
- | ||
name: Generate Changelog | ||
run: make generate-changelog-ci | ||
if: steps.changes.outputs.any_changed == 'true' | ||
|
||
# https://github.com/peter-evans/create-pull-request#action-inputs | ||
- | ||
name: Create Pull Request | ||
uses: peter-evans/create-pull-request@v4 | ||
with: | ||
token: "${{ secrets.GITHUB_TOKEN }}" | ||
branch: "change/${{ github.sha }}" | ||
commit-message: "new changes" | ||
title: "maybe new release?" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
name: Build and Push Docker Images | ||
|
||
on: | ||
push: | ||
branches: | ||
- "*" | ||
tags: | ||
- "*" | ||
|
||
jobs: | ||
|
||
Docker: | ||
name: Build and Push Docker Images | ||
runs-on: ubuntu-latest | ||
outputs: | ||
matrix: ${{ steps.set-matrix.outputs.matrix }} | ||
|
||
steps: | ||
|
||
- | ||
name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- | ||
name: Set up Docker Build | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- | ||
name: Build Docker Test Image | ||
uses: docker/build-push-action@v3 | ||
id: build | ||
with: | ||
context: . | ||
load: true | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
|
||
- | ||
name: Test Docker Image | ||
run: | | ||
CMD="docker run --rm -i -p 9001:9001 ${{ steps.build.outputs.imageid }} --port=9001" ./test.sh | ||
- name: Get Docker Image Metadata | ||
id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: | | ||
quay.io/k8start/http-headers | ||
ghcr.io/bukowa/http-headers | ||
bukowa/http-headers | ||
tags: | | ||
type=schedule | ||
type=semver,pattern={{version}} | ||
type=semver,pattern={{major}}.{{minor}} | ||
type=semver,pattern={{major}} | ||
type=ref,event=branch | ||
type=ref,event=pr | ||
- name: Set up QEMU | ||
id: qemu | ||
uses: docker/setup-qemu-action@v2 | ||
|
||
- name: Login to Docker Hub Container Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_ROBOT_TOKEN }} | ||
|
||
- name: Login to GHCR.io Container Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Login to Quay.io Container Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: quay.io | ||
username: ${{ secrets.QUAY_USERNAME }} | ||
password: ${{ secrets.QUAY_ROBOT_TOKEN }} | ||
|
||
# - name: Get Docker Expire Image Metadata | ||
# id: meta-expire | ||
# uses: docker/metadata-action@v4 | ||
# with: | ||
# images: | | ||
# quay.io/k8start/http-headers | ||
# tags: | | ||
# type=sha | ||
|
||
# - | ||
# # Push images that expire | ||
# name: Build and Push Docker Expire Images | ||
# uses: docker/build-push-action@v3 | ||
# with: | ||
# context: . | ||
# push: true | ||
# tags: ${{ steps.meta-expire.outputs.tags }} | ||
# labels: | | ||
# quay.expires-after=72h | ||
# ${{ steps.meta-expire.outputs.labels }} | ||
# cache-from: | | ||
# type=gha | ||
# type=registry,ref=quay.io/k8start/http-headers | ||
# cache-to: | | ||
# type=gha,mode=max | ||
# platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x | ||
|
||
- | ||
# Push other images | ||
name: Build and Push Docker Images | ||
uses: docker/build-push-action@v3 | ||
id: build-all | ||
with: | ||
context: . | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: | | ||
${{ steps.meta.outputs.labels }} | ||
cache-from: | | ||
type=gha | ||
type=registry,ref=quay.io/k8start/http-headers | ||
cache-to: | | ||
type=gha,mode=max | ||
platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Test | ||
|
||
on: | ||
pull_request: | ||
|
||
jobs: | ||
|
||
Docker: | ||
name: Test in Docker | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- | ||
name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- | ||
name: Set up Docker Build | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- | ||
name: Build Docker Test Image | ||
uses: docker/build-push-action@v3 | ||
id: build | ||
with: | ||
context: . | ||
load: true | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
|
||
- | ||
name: Test Docker Image | ||
run: | | ||
CMD="docker run --rm -i -p 9001:9001 ${{ steps.build.outputs.imageid }} --port=9001" ./test.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
FROM golang:1.19-alpine as builder | ||
COPY main.go . | ||
ENV CGO_ENABLED=0 | ||
RUN go build -o /app main.go | ||
|
||
FROM alpine | ||
LABEL maintainer="github.com/bukowa" | ||
|
||
# Define GOTRACEBACK to mark this container as using the Go language runtime | ||
# for `skaffold debug` (https://skaffold.dev/docs/workflows/debug/). | ||
ENV GOTRACEBACK=single | ||
ENTRYPOINT ["./app"] | ||
COPY --from=builder /app . | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
generate-changelog: | ||
./scripts/generate-changelog.sh | ||
|
||
generate-changelog-ci: | ||
touch CHANGELOG.md CHANGELOG.LATEST.md \ | ||
&& \ | ||
./scripts/generate-changelog.sh \ | ||
-u --prepend=CHANGELOG.md \ | ||
--include-path "*.go" \ | ||
--include-path "*.mod" \ | ||
--include-path "*Dockerfile" \ | ||
&& \ | ||
./scripts/generate-changelog.sh \ | ||
-u --output=CHANGELOG.LATEST.md \ | ||
--include-path "*.go" \ | ||
--include-path "*.mod" \ | ||
--include-path "*Dockerfile" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# configuration file for git-cliff (0.1.0) | ||
|
||
[changelog] | ||
# changelog header | ||
header = """ | ||
# Changelog\n | ||
All notable changes to this project will be documented in this file.\n | ||
""" | ||
# template for the changelog body | ||
# https://tera.netlify.app/docs/#introduction | ||
body = """ | ||
{% if version %}\ | ||
## [{{ version | trim_start_matches(pat="[-[:alpha:]]") }}] - {{ timestamp | date(format="%Y-%m-%d") }} | ||
{% else %}\ | ||
## [unreleased] | ||
{% endif %}\ | ||
{% for group, commits in commits | group_by(attribute="group") %} | ||
### {{ group | upper_first }} | ||
{% for commit in commits %} | ||
- {% if commit.breaking %}[**breaking**] {% endif %}{{ commit.message }}\ | ||
{% endfor %} | ||
{% endfor %}\n | ||
""" | ||
# remove the leading and trailing whitespace from the template | ||
trim = true | ||
# changelog footer | ||
footer = """ | ||
<!-- generated by git-cliff --> | ||
""" | ||
|
||
[git] | ||
# parse the commits based on https://www.conventionalcommits.org | ||
conventional_commits = true | ||
# filter out the commits that are not conventional | ||
filter_unconventional = false | ||
# process each line of a commit as an individual commit | ||
split_commits = false | ||
# regex for preprocessing the commit messages | ||
commit_preprocessors = [ | ||
{ pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](https://github.com/bukowa/http-headers/issues/${2}))"}, | ||
] | ||
# regex for parsing and grouping commits | ||
commit_parsers = [ | ||
{ message = "^feat", group = "Features"}, | ||
{ message = "^fix", group = "Bug Fixes"}, | ||
{ message = "^doc", group = "Documentation"}, | ||
{ message = "^perf", group = "Performance"}, | ||
{ message = "^refactor", group = "Refactor"}, | ||
{ message = "^style", group = "Styling"}, | ||
{ message = "^test", group = "Testing"}, | ||
{ message = "^build", group = "Build"}, | ||
{ message = "^chore\\(release\\): prepare for", skip = true}, | ||
{ message = "^chore", group = "Miscellaneous Tasks"}, | ||
{ message = "^add", group = "Core"}, | ||
{ body = ".*security", group = "Security"}, | ||
] | ||
# filter out the commits that are not matched by commit parsers | ||
filter_commits = true | ||
# glob pattern for matching git tags | ||
tag_pattern = "[0-9].[0-9].[0-9].*" | ||
# regex for skipping tags | ||
skip_tags = "v0.1.0-beta.1" | ||
# regex for ignoring tags | ||
ignore_tags = "" | ||
# sort the tags chronologically | ||
date_order = false | ||
# sort the commits inside sections by oldest/newest order | ||
sort_commits = "oldest" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
set -eux | ||
|
||
echo "Building docker image for git-cliff..." | ||
|
||
GIT_CLIFF=$(docker build -q - <<EOF | ||
FROM ghcr.io/orhun/git-cliff/git-cliff:sha-0f38960 | ||
WORKDIR /workdirvol | ||
ENTRYPOINT ["git-cliff"] | ||
EOF | ||
) | ||
|
||
echo "Running docker image for git-cliff..." | ||
docker run --rm \ | ||
--volume="${PWD}:/workdirvol" \ | ||
-u "$(id -u)" \ | ||
"${GIT_CLIFF}" \ | ||
"$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters