Pass through version argument #332
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: ci | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
workflow_dispatch: | |
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 | |
- uses: dorny/paths-filter@v2 | |
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/**' | |
# 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 | |
- name: Build locally for testing | |
uses: docker/build-push-action@v3 | |
with: | |
load: true | |
context: ${{ matrix.image }} | |
file: ${{ matrix.image }}/Containerfile | |
tags: ${{ env.tags }} | |
- name: Run tests on the image with cinc-auditor | |
run: | | |
$(git rev-parse --show-toplevel)/bin/test.sh | |
- 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.release.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.release.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 | |