Build and push OCI image #256
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
name: Build and push OCI image | |
on: | |
schedule: | |
- cron: '7 7 * * *' # UTC | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
shellcheck: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Run ShellCheck | |
uses: ludeeus/action-shellcheck@master | |
env: | |
SHELLCHECK_OPTS: -e SC3037 -e SC3060 | |
- name: Max. 79 characters per line | |
run: | | |
wc -L *.sh | sort -nr | |
MLL=$(gawk '{ if(length > L) { L=length } } END { print L }' *.sh) | |
(( ${MLL:-80} <= 79 )) || exit 1 | |
build: | |
needs: shellcheck | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Create image metadata | |
id: meta | |
run: echo "created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to Docker Hub | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Login to Quay Container Registry | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v2 | |
with: | |
registry: quay.io | |
username: ${{ secrets.QUAY_USERNAME }} | |
password: ${{ secrets.QUAY_TOKEN }} | |
- name: Multi-arch Dockerfile | |
run: sed -e 's/^\(FROM\) \(alpine:.*\)/ARG ARCH=\n\1 ${ARCH}\2/' -i Dockerfile | |
- name: Build and push image | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: | | |
smblds/smblds:latest | |
quay.io/smblds/smblds:latest | |
labels: | | |
org.opencontainers.image.created=${{ steps.meta.outputs.created }} | |
org.opencontainers.image.revision=${{ github.sha }} | |
org.label-schema.build-date=${{ steps.meta.outputs.created }} | |
org.label-schema.vcs-ref=${{ github.sha }} | |
check: | |
needs: build | |
runs-on: ubuntu-latest | |
container: smblds/smblds:latest | |
steps: | |
- name: Run ENTRYPOINT explicitly | |
run: /entrypoint.sh /bin/sh | |
- name: Run ldbsearch against Samba | |
run: ldbsearch -H /var/lib/samba/private/sam.ldb > /dev/null | |
- name: Wait for started Samba services | |
run: for cnt in $(seq 1 9); do netstat -lnpt | grep :389 && netstat -lnpt | grep :636 && break || sleep 1; done | |
- name: Run ldapsearch against Samba | |
run: ldapsearch -v > /dev/null |