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

Build a container for CI usage #29

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
72 changes: 72 additions & 0 deletions .github/workflows/container.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
name: build container

on:
push:
paths:
- .github/workflows/container.yml
- Dockerfile
- gnitpick.py
pull_request:
paths:
- .github/workflows/container.yml
- Dockerfile
- gnitpick.py

jobs:
build:
runs-on: ubuntu-latest
services:
registry:
image: registry:2
ports:
- 5000:5000
env:
DEPLOY_IMAGES: false

steps:
- uses: actions/checkout@v2
- name: Check Dockerfile with hadolint
run: |
docker run -i -v $(pwd):/mnt -w /mnt hadolint/hadolint:latest hadolint /mnt/Dockerfile
- name: Build image
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: localhost:5000/test/gnitpick:latest
- name: Check container
run: |
docker run -i -v $(pwd):/mnt -w /mnt localhost:5000/test/gnitpick:latest gnitpick -h
- name: Check for registry credentials
if: >
github.ref == 'refs/heads/master' &&
github.repository == 'Seravo/gnitpick'
run: |
missing=()
[[ -n "${{ secrets.REGISTRY_USER }}" ]] || missing+=(REGISTRY_USER)
[[ -n "${{ secrets.REGISTRY_TOKEN }}" ]] || missing+=(REGISTRY_TOKEN)
for i in "${missing[@]}"; do
echo "Missing github secret: $i"
done
if (( ${#missing[@]} == 0 )); then
echo "DEPLOY_IMAGES=true" >> $GITHUB_ENV
else
echo "Not pushing images to registry"
fi
- name: Login to registry
if: ${{ env.DEPLOY_IMAGES == 'true' }}
uses: docker/login-action@v1
with:
registry: registry.com
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_TOKEN }}
- name: Push images to registry
if: ${{ env.DEPLOY_IMAGES == 'true' }}
run: |
msg="Push docker image to registry"
line="${msg//?/=}"
printf "\n${line}\n${msg}\n${line}\n"
skopeo copy --all --src-tls-verify=0 \
docker://localhost:5000/test/gnitpick:latest \
docker://registry.com/Seravo/gnitpick:latest
3 changes: 3 additions & 0 deletions .hadolint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
ignored:
- DL3008
18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM debian:11-slim

RUN set -eux \
&& apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
ca-certificates \
curl \
git \
python3-minimal \
&& rm -rf /var/lib/apt/lists/* \
/var/cache/debconf/* \
&& apt-get clean

COPY gnitpick.py /usr/bin/gnitpick

RUN chmod +x /usr/bin/gnitpick

CMD ["/usr/bin/gnitpick"]