Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add ci and container build #2

Merged
merged 4 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions .github/workflows/build_docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
name: Build and publish a 🛢️ container

on:
push:
branches:
- 'main'
tags:
- '*'
workflow_dispatch:

jobs:
setup-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Source checkout
uses: actions/checkout@v4

- id: set-matrix
run: echo "matrix=$(cat build_versions.json | jq -c)" >> $GITHUB_OUTPUT

build-and-push-container:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
needs: setup-matrix
strategy:
matrix: ${{ fromJson(needs.setup-matrix.outputs.matrix) }}
steps:
- name: Build R10K ${{ matrix.rubygem_r10k }} container
uses: voxpupuli/gha-build-and-publish-a-container@v2
with:
registry_password: ${{ secrets.GITHUB_TOKEN }}
build_args: |
RUBYGEM_R10K=${{ matrix.rubygem_r10k }}
APK_GIT=${{ matrix.apk_git }}
build_arch: linux/amd64,linux/arm64
docker_username: voxpupulibot
docker_password: ${{ secrets.DOCKERHUB_BOT_PASSWORD }}
build_context: .
buildfile: Dockerfile
tags: |
ghcr.io/voxpupuli/r10k:${{ matrix.rubygem_r10k }}-${{ github.ref_name }}
ghcr.io/voxpupuli/r10k:${{ matrix.rubygem_r10k }}-latest
ghcr.io/voxpupuli/r10k:latest
docker.io/voxpupuli/r10k:${{ matrix.rubygem_r10k }}-${{ github.ref_name }}
docker.io/voxpupuli/r10k:${{ matrix.rubygem_r10k }}-latest
docker.io/voxpupuli/r10k:latest

- name: Update Docker Hub Description
uses: peter-evans/dockerhub-description@v4
with:
username: voxpupulibot
password: ${{ secrets.DOCKERHUB_BOT_PASSWORD }}

- name: Update Docker Hub Description for shortname
uses: peter-evans/dockerhub-description@v4
with:
username: voxpupulibot
password: ${{ secrets.DOCKERHUB_BOT_PASSWORD }}
repository: voxpupuli/r10k
80 changes: 80 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
---
name: CI🚦

on:
pull_request:
branches:
- main
workflow_dispatch:

jobs:
setup-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Source checkout
uses: actions/checkout@v4

- id: set-matrix
run: echo "matrix=$(jq -c . build_versions.json)" >> $GITHUB_OUTPUT

# general_ci:
# uses: voxpupuli/crafty/.github/workflows/general_ci.yaml@main
# with:
# shellcheck_scan_dir: '.'

build_test_container:
name: 'Build test container'
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
pull-requests: write
needs: setup-matrix
strategy:
matrix: ${{ fromJson(needs.setup-matrix.outputs.matrix) }}
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Build image
uses: docker/build-push-action@v6
with:
tags: 'ci/r10k:${{ matrix.rubygem_r10k }}'
context: .
push: false
build-args: |
RUBYGEM_R10K=${{ matrix.rubygem_r10k }}
APK_GIT=${{ matrix.apk_git }}

tests:
needs:
# - general_ci
- build_test_container
runs-on: ubuntu-latest
name: Test suite
steps:
- run: echo Test suite completed

dependabot:
permissions:
contents: write
name: 'Dependabot auto-merge'
needs:
- tests
runs-on: ubuntu-latest
if: ${{ github.actor == 'dependabot[bot]' && github.event_name == 'pull_request'}}
steps:
- name: Dependabot metadata
id: metadata
uses: dependabot/[email protected]
with:
github-token: '${{ secrets.GITHUB_TOKEN }}'

- name: Enable auto-merge for Dependabot PRs
run: gh pr merge --auto --merge "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
17 changes: 17 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# How to contribute

PRs are very welcome!

## Adding code

- Create a fork
- Create a branch
- Do your thing
- [Please sign all your commits](https://docs.github.com/de/authentication/managing-commit-signature-verification)
- Create a PR
- Reference issues if applicable

## Found a bug?

- Please open an issue
- If you are able to fix it you also can open a PR (see above)
13 changes: 7 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM alpine:3.20

ARG VERSION="4.1.0"
ARG APK_GIT=2.45.2-r0
ARG RUBYGEM_R10K=4.1.0

LABEL org.label-schema.maintainer="Voxpupuli Team <[email protected]>" \
org.label-schema.vendor="Voxpupuli" \
Expand All @@ -10,7 +11,7 @@ LABEL org.label-schema.maintainer="Voxpupuli Team <[email protected]>" \
org.label-schema.vcs-url="https://github.com/voxpupuli/container-r10k" \
org.label-schema.schema-version="1.0" \
org.label-schema.dockerfile="/Dockerfile" \
org.label-schema.version="$VERSION"
org.label-schema.version="$RUBYGEM_R10K"

# in alpine 3.20 "ping" is the group of id 999
RUN adduser -G ping -D -u 999 puppet
Expand All @@ -19,16 +20,16 @@ RUN apk update \
&& apk upgrade \
&& apk add --no-cache \
gcc \
git \
git=${APK_GIT} \
libssh2 \
make \
musl-dev \
openssh-client \
ruby \
ruby-dev \
ruby-rugged \
libssh2-1
ruby-rugged

RUN gem install --no-doc r10k:"$VERSION"
RUN gem install --no-doc r10k:"$RUBYGEM_R10K"

USER puppet
WORKDIR /home/puppet
Expand Down
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,39 @@
## Introduction

This container should be used to deploy code with r10k. It has the r10k gem and all dependencies installed.

## Version Schema

The version schema has the following layout:

```text
<puppet.major>.<puppet.minor>.<puppet.patch>-v<container.major>.<container.minor>.<container.patch>
rwaffen marked this conversation as resolved.
Show resolved Hide resolved
<puppet.major>-v<container.major>.<container.minor>.<container.patch>
<puppet.major>
latest
```

Example usage:

```shell
docker pull ghcr.io/voxpupuli/r10k:4.1.0-v1.2.3
docker pull ghcr.io/voxpupuli/r10k:4.1.0-latest
docker pull ghcr.io/voxpupuli/r10k:latest
```

| Name | Description |
| --- | --- |
| r10k.major | Describes the contained major r10k version |
| r10k.minor | Describes the contained minor r10k version |
| r10k.patch | Describes the contained patch r10k version |
| container.major | Describes breaking changes without backward compatibility |
| container.minor | Describes new features or refactoring with backward compatibility |
| container.patch | Describes if minor changes or bugfixes have been implemented |

## How to release?

see [RELEASE.md](RELEASE.md)

## How to contribute?

see [CONTRIBUTING.md](CONTRIBUTING.md)
8 changes: 8 additions & 0 deletions build_versions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"include": [
{
"rubygem_r10k": "4.1.0",
rwaffen marked this conversation as resolved.
Show resolved Hide resolved
"apk_git": "2.45.2-r0"
}
]
}
Loading