Build & push docker images #286
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 | |
run-name: Build & push docker images | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- 'main' | |
- 'dev' | |
# Daily, at 00:30 | |
schedule: | |
- cron: '30 0 * * *' | |
jobs: | |
build: | |
strategy: | |
matrix: | |
data: | |
- package: ansible-core | |
- package: ansible-core | |
version: 2.16 | |
- package: ansible-core | |
version: 2.17 | |
- package: ansible | |
- package: ansible | |
version: 9.* | |
- package: ansible | |
version: 10.* | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: 'Print docker version information' | |
run: | | |
docker --version | |
- name: 'Set up Docker Buildx' | |
uses: docker/setup-buildx-action@v3 | |
- name: 'Login to Docker Hub' | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: 'Set Docker meta' | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: thehedhly/${{ matrix.data.package }} | |
labels: | | |
org.opencontainers.image.version=${{ matrix.data.version == '' && 'latest' || matrix.data.version }} | |
org.opencontainers.image.description=A minimal ${{ matrix.data.package }} image for efficient infrastructure as code | |
tags: | | |
type=raw,value=${{ matrix.data.version == '' && 'latest' || matrix.data.version }} | |
- name: 'Build and push' | |
uses: docker/build-push-action@v6 | |
with: | |
push: true | |
context: . | |
file: Dockerfile | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
build-args: | | |
ANSIBLE_INSTALL_REFS=${{ matrix.data.version == '' && matrix.data.package || format('{0}=={1}',matrix.data.package,matrix.data.version) }} |