-
-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from cytopia/major-update
Major update
- Loading branch information
Showing
15 changed files
with
690 additions
and
455 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
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
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,251 @@ | ||
name: Build multi-arch image | ||
|
||
on: | ||
workflow_call: | ||
### | ||
### Variables | ||
### | ||
inputs: | ||
enabled: | ||
description: 'Determines wheather this workflow is enabled at all (will run or skip).' | ||
required: true | ||
type: boolean | ||
can_deploy: | ||
description: 'Determines wheather this workflow will also deploy (login and push).' | ||
required: true | ||
type: boolean | ||
matrix: | ||
description: 'The version build matrix as JSON string ( list of objects: [{NAME, VERSION[], ARCH[]}] ).' | ||
required: true | ||
type: string | ||
refs: | ||
description: 'The ref build matrix as JSON string (list of git refs to build/deploy).' | ||
required: false | ||
type: string | ||
### | ||
### Secrets | ||
### | ||
secrets: | ||
dockerhub_username: | ||
description: 'The username for Dockerhub.' | ||
required: false | ||
dockerhub_password: | ||
description: 'The password for Dockerhub.' | ||
required: false | ||
|
||
jobs: | ||
|
||
# ----------------------------------------------------------------------------------------------- | ||
# JOB (1/3): CONFIGURE | ||
# ----------------------------------------------------------------------------------------------- | ||
configure: | ||
name: Configure | ||
runs-on: ubuntu-latest | ||
outputs: | ||
can_login: ${{ steps.set-login.outputs.can_login }} | ||
has_refs: ${{ steps.set-matrix.outputs.has_refs }} | ||
matrix_build: ${{ steps.set-matrix.outputs.matrix_build }} | ||
matrix_deploy: ${{ steps.set-matrix.outputs.matrix_deploy }} | ||
if: inputs.enabled | ||
steps: | ||
- name: "[Set-Output] Set Docker login capabilities" | ||
id: set-login | ||
shell: bash | ||
run: | | ||
if [ "${{ env.ENV_USER }}" = '' ] || [ "${{ env.ENV_PASS }}" = '' ]; then | ||
echo "::set-output name=can_login::0" | ||
else | ||
echo "::set-output name=can_login::1" | ||
fi | ||
env: | ||
ENV_USER: ${{ secrets.dockerhub_username }} | ||
ENV_PASS: ${{ secrets.dockerhub_password }} | ||
|
||
- name: "[Set-Output] Set Build & Deploy Matrix" | ||
id: set-matrix | ||
shell: bash | ||
run: | | ||
if [ "${{ inputs.refs }}" != "" ]; then | ||
MATRIX_BUILD="$( \ | ||
jq -M -c \ | ||
--argjson refs '${{ inputs.refs }}' \ | ||
'map({name:.NAME, version:.VERSION[], arch:.ARCH[], refs:$refs[]})' <<<'${{ inputs.matrix }}' \ | ||
)" | ||
MATRIX_DEPLOY="$( \ | ||
jq -M -c \ | ||
--argjson refs '${{ inputs.refs }}' \ | ||
'map({name:.NAME, version:.VERSION[], refs:$refs[]})' <<<'${{ inputs.matrix }}' \ | ||
)" | ||
echo "::set-output name=matrix_build::${MATRIX_BUILD}" | ||
echo "::set-output name=matrix_deploy::${MATRIX_DEPLOY}" | ||
echo "::set-output name=has_refs::1" | ||
else | ||
MATRIX_BUILD="$( \ | ||
jq -M -c \ | ||
'map({name:.NAME, version:.VERSION[], arch:.ARCH[]})' <<<'${{ inputs.matrix }}' \ | ||
)" | ||
MATRIX_DEPLOY="$( \ | ||
jq -M -c \ | ||
'map({name:.NAME, version:.VERSION[]})' <<<'${{ inputs.matrix }}' \ | ||
)" | ||
echo "::set-output name=matrix_build::${MATRIX_BUILD}" | ||
echo "::set-output name=matrix_deploy::${MATRIX_DEPLOY}" | ||
echo "::set-output name=has_refs::0" | ||
fi | ||
- name: "[DEBUG] Workflow Inputs" | ||
shell: bash | ||
run: | | ||
echo 'enabled: ${{ inputs.enabled }} ' | ||
echo 'can_deploy: ${{ inputs.can_deploy }} ' | ||
echo 'matrix: ${{ inputs.matrix }} ' | ||
echo 'refs: ${{ inputs.refs }} ' | ||
- name: "[DEBUG] Determined Settings" | ||
shell: bash | ||
run: | | ||
echo 'can_login=${{ steps.set-login.outputs.can_login }}' | ||
echo 'has_refs=${{ steps.set-matrix.outputs.has_refs }}' | ||
echo 'matrix_build=${{ steps.set-matrix.outputs.matrix_build }}' | ||
echo 'matrix_deploy=${{ steps.set-matrix.outputs.matrix_deploy }}' | ||
# ----------------------------------------------------------------------------------------------- | ||
# JOB (2/3): BUILD | ||
# ----------------------------------------------------------------------------------------------- | ||
build: | ||
needs: [configure] | ||
name: Build ${{ matrix.name }}-${{ matrix.version }} (${{ matrix.arch }}) ${{ matrix.refs }} | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: ${{ fromJson(needs.configure.outputs.matrix_build) }} | ||
if: inputs.enabled | ||
steps: | ||
# ------------------------------------------------------------ | ||
# Setup repository | ||
# ------------------------------------------------------------ | ||
- name: "[SETUP] Checkout repository (current)" | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
if: needs.configure.outputs.has_refs == 0 | ||
|
||
- name: "[SETUP] Checkout repository (ref: ${{ matrix.refs }})" | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
ref: ${{ matrix.refs }} | ||
if: needs.configure.outputs.has_refs != 0 | ||
|
||
- name: "[SETUP] Setup QEMU environment" | ||
uses: docker/setup-qemu-action@v1 | ||
with: | ||
image: tonistiigi/binfmt:latest | ||
platforms: all | ||
|
||
- name: "[SETUP] Determine Docker tag" | ||
id: tag | ||
uses: cytopia/[email protected] | ||
|
||
# ------------------------------------------------------------ | ||
# Build | ||
# ------------------------------------------------------------ | ||
- name: Build | ||
uses: cytopia/[email protected] | ||
with: | ||
command: | | ||
make build NAME=${{ matrix.name }} VERSION=${{ matrix.version }} ARCH=${{ matrix.arch }} TAG=${{ steps.tag.outputs.docker-tag }} | ||
# ------------------------------------------------------------ | ||
# Test | ||
# ------------------------------------------------------------ | ||
- name: Test | ||
uses: cytopia/[email protected] | ||
with: | ||
command: | | ||
make test NAME=${{ matrix.name }} VERSION=${{ matrix.version }} ARCH=${{ matrix.arch }} TAG=${{ steps.tag.outputs.docker-tag }} | ||
# ------------------------------------------------------------ | ||
# Deploy | ||
# ------------------------------------------------------------ | ||
- name: Docker login | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.dockerhub_username }} | ||
password: ${{ secrets.dockerhub_password }} | ||
if: needs.configure.outputs.can_login == 1 && inputs.can_deploy | ||
|
||
- name: Docker push architecture image | ||
uses: cytopia/[email protected] | ||
with: | ||
command: | | ||
make push NAME=${{ matrix.name }} VERSION=${{ matrix.version }} ARCH=${{ matrix.arch }} TAG=${{ steps.tag.outputs.docker-tag }} | ||
if: needs.configure.outputs.can_login == 1 && inputs.can_deploy | ||
|
||
# ----------------------------------------------------------------------------------------------- | ||
# JOB (3/3): DEPLOY | ||
# ----------------------------------------------------------------------------------------------- | ||
deploy: | ||
needs: [configure, build] | ||
name: Deploy ${{ matrix.name }}-${{ matrix.version }} ${{ matrix.refs }} | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: ${{ fromJson(needs.configure.outputs.matrix_deploy) }} | ||
if: inputs.enabled && needs.configure.outputs.can_login == 1 && inputs.can_deploy | ||
steps: | ||
# ------------------------------------------------------------ | ||
# Setup repository | ||
# ------------------------------------------------------------ | ||
- name: "[SETUP] Checkout repository (current)" | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
if: needs.configure.outputs.has_refs == 0 | ||
|
||
- name: "[SETUP] Checkout repository (ref: ${{ matrix.refs }})" | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
ref: ${{ matrix.refs }} | ||
if: needs.configure.outputs.has_refs != 0 | ||
|
||
- name: "[SETUP] Determine Docker tag" | ||
id: tag | ||
uses: cytopia/[email protected] | ||
|
||
- name: "[SETUP] Determine manifest arches" | ||
id: manifest | ||
run: | | ||
ARCHES="$( echo '${{ inputs.matrix }}' \ | ||
| jq 'group_by(.NAME, .VERSION, .ARCH)' \ | ||
| jq 'map({NAME: .[].NAME, VERSION: .[].VERSION[], ARCHES: .[].ARCH|join(",")})' \ | ||
| jq '.[] | select(.NAME=="${{ matrix.name }}" and .VERSION=="${{ matrix.version }}") | .ARCHES' \ | ||
| jq -c -M \ | ||
)" | ||
echo "::set-output name=arches::${ARCHES}" | ||
echo "ARCHES: ${ARCHES}" | ||
# ------------------------------------------------------------ | ||
# Deploy | ||
# ------------------------------------------------------------ | ||
- name: "[DEPLOY] Login" | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_PASSWORD }} | ||
|
||
- name: "[DEPLOY] Create Docker manifest for architectures: ${{ steps.manifest.outputs.arches }}" | ||
uses: cytopia/[email protected] | ||
with: | ||
command: | | ||
make manifest-create NAME=${{ matrix.name }} VERSION=${{ matrix.version }} ARCHES=${{ steps.manifest.outputs.arches }} TAG=${{ steps.tag.outputs.docker-tag }} | ||
- name: "[DEPLOY] Publish Docker manifest: ${{ steps.tag.outputs.docker-tag }}" | ||
uses: cytopia/[email protected] | ||
with: | ||
command: | | ||
make manifest-push NAME=${{ matrix.name }} VERSION=${{ matrix.version }} TAG=${{ steps.tag.outputs.docker-tag }} |
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,43 @@ | ||
name: Lint | ||
|
||
on: | ||
workflow_call: | ||
|
||
jobs: | ||
|
||
# ----------------------------------------------------------------------------------------------- | ||
# JOB (1/1): Lint | ||
# ----------------------------------------------------------------------------------------------- | ||
lint: | ||
name: lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- name: "[SETUP] Checkout repository" | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Lint Files | ||
uses: cytopia/[email protected] | ||
with: | ||
command: | | ||
make lint-files | ||
- name: Lint Yaml | ||
uses: cytopia/[email protected] | ||
with: | ||
command: | | ||
make lint-yaml | ||
- name: Lint JSON | ||
uses: cytopia/[email protected] | ||
with: | ||
command: | | ||
make lint-json | ||
- name: Lint Bash | ||
uses: cytopia/[email protected] | ||
with: | ||
command: | | ||
make lint-bash |
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 |
---|---|---|
|
@@ -6,12 +6,12 @@ LABEL org.opencontainers.image.authors="[email protected]" | |
### Install | ||
### | ||
RUN set -eux \ | ||
&& apt-get update \ | ||
&& apt-get install --no-install-recommends --no-install-suggests -y \ | ||
&& apt update \ | ||
&& apt install --no-install-recommends --no-install-suggests -y \ | ||
bind9 \ | ||
dnsutils \ | ||
iputils-ping \ | ||
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \ | ||
#nsutils \ | ||
#putils-ping \ | ||
&& apt purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \ | ||
&& rm -r /var/lib/apt/lists/* \ | ||
&& mkdir /var/log/named \ | ||
&& chown bind:bind /var/log/named \ | ||
|
Oops, something went wrong.