Skip to content

Update image locations #351

Update image locations

Update image locations #351

Workflow file for this run

name: ci
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
inputs:
build_context:
description: 'Build directory'
required: true
jobs:
# Job to run change detection
changes:
runs-on: ubuntu-latest
outputs:
# Expose matched filters as job 'images' output variable
images: ${{ steps.filter.outputs.changes }}
steps:
- uses: actions/checkout@v4
- name: Set context from workflow_dispatch
if: github.event_name != 'workflow_dispatch'
id: manual_filter
run: |
echo "changes={ ${{ inputs.build_context}}: '${{ inputs.build_context}}/**' }"
- uses: dorny/paths-filter@v2
if: github.event_name != 'workflow_dispatch'
id: filter
with:
# Use context to get the branch where commits were pushed.
# If there is only one long-lived branch (e.g. master),
# you can specify it directly.
# If it's not configured, the repository default branch is used.
base: ${{ github.ref }}
filters: |
aws-cli: 'aws-cli/**'
meshcmd: 'meshcmd/**'
# Job to build and test each of the modified images
build:
needs: changes
strategy:
matrix:
# Parse JSON array containing names of all filters matching any of changed files
# e.g. ['image1', 'image2'] if both image folders contains changes
image: ${{ fromJSON(needs.changes.outputs.images) }}
if: ${{ needs.changes.outputs.images != '[]' && needs.changes.outputs.images != '' }}
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ matrix.image }}
steps:
- uses: actions/checkout@v4
- name: Check the Containerfile with hadolint
run: |
$(git rev-parse --show-toplevel)/bin/lint.sh
- name: Install QEMU static binaries
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Build locally for testing
uses: docker/bake-action@v4
with:
workdir: ${{ matrix.image }}
targets: local
load: true
- name: Run tests on the image with cinc-auditor
run: |
$(git rev-parse --show-toplevel)/bin/test.sh
- name: Login to DockerHub
if: github.event_name == 'push'
uses: docker/login-action@v2
with:
username: ${{ secrets.CONTAINER_REGISTRY_USERNAME }}
password: ${{ secrets.CONTAINER_REGISTRY_PASSWORD }}
- name: Build and push
uses: docker/bake-action@v4
with:
workdir: ${{ matrix.image }}
push: ${{ github.event_name != 'pull_request' }}
- name: Get the image name
if: github.event_name != 'pull_request'
id: image_name
run: |
echo "image_name=$(docker buildx bake --print 2>/dev/null | jq -r '.target.default.labels."org.opencontainers.image.title"')" >> $GITHUB_ENV
- name: Get the image description
if: github.event_name != 'pull_request'
id: image_description
run: |
echo "image_description=$(docker buildx bake --print 2>/dev/null | jq -r '.target.default.labels."org.opencontainers.image.description"')" >> $GITHUB_ENV
- name: Update Docker Hub Description
if: github.event_name != 'pull_request'
uses: peter-evans/dockerhub-description@v3
with:
username: ${{ secrets.CONTAINER_REGISTRY_USERNAME }}
password: ${{ secrets.CONTAINER_DESCRIPTION_PASSWORD }}
repository: boxcutter/${{ env.image_name }}
short-description: ${{ env.image_description }}
readme-filepath: ${{ matrix.image }}/README.md