vegardit-docker-openldap/.github/workflows/build.yml
2023-06-23 12:32:17 +02:00

77 lines
2.4 KiB
YAML

# SPDX-FileCopyrightText: © Vegard IT GmbH (https://vegardit.com)
# SPDX-FileContributor: Sebastian Thomschke
# SPDX-License-Identifier: Apache-2.0
# SPDX-ArtifactOfProjectHomePage: https://github.com/vegardit/docker-openldap
#
# https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions
name: Build
on:
push:
branches: # build all branches
- '**'
tags-ignore: # but don't build tags
- '**'
paths-ignore:
- '**/*.md'
- '.github/*.yml'
schedule:
# https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows
- cron: '0 0 * * *'
pull_request:
workflow_dispatch:
# https://github.blog/changelog/2020-07-06-github-actions-manual-triggers-with-workflow_dispatch/
env:
DOCKER_IMAGE_REPO: vegardit/openldap
TRIVY_CACHE_DIR: ~/.trivy/cache
defaults:
run:
shell: bash
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Show environment variables
run: env | sort
- name: Git Checkout
uses: actions/checkout@v3 #https://github.com/actions/checkout
- name: Cache trivy cache
uses: actions/cache@v3
with:
path: ${{ env.TRIVY_CACHE_DIR }}
# https://github.com/actions/cache/issues/342#issuecomment-673371329
key: ${{ runner.os }}-trivy-${{ github.run_id }}
restore-keys: |
${{ runner.os }}-trivy-
- name: Configure fast APT repository mirror
uses: vegardit/fast-apt-mirror.sh@v1
- name: Install dos2unix
run: sudo apt-get install --no-install-recommends -y dos2unix
- name: Install regclient
if: ${{ github.ref_name == 'main' && github.event_name != 'pull_request' && !env.ACT }} # https://github.com/nektos/act#skipping-steps
uses: iarekylew00t/regctl-installer@v1
- name: Login to docker.io
if: ${{ github.ref_name == 'main' && github.event_name != 'pull_request' && !env.ACT }} # https://github.com/nektos/act#skipping-steps
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: Build docker image
env:
DOCKER_REGISTRY: docker.io
DOCKER_PUSH: ${{ github.ref_name == 'main' && github.event_name != 'pull_request' && !env.ACT }}
TRIVY_GITHUB_TOKEN: ${{ github.token }}
run: |
bash build-image.sh