Skip to content

Update docker/build-push-action action to v6 #215

Update docker/build-push-action action to v6

Update docker/build-push-action action to v6 #215

Workflow file for this run

name: Docker Build ⚓
on: [push, pull_request]
jobs:
# Single job now to build Docker Image, run GHC unit tests, and push to DockerHub
build_test_push:
name: Build and Publish
runs-on: ubuntu-latest
strategy:
matrix:
include:
- output: "elasticsearch"
logstash-version: 7.17.14
logstash-branch: 7.17
elasticsearch-version: 7
prefix: ""
tags-latest: "latest"
- output: "elasticsearch"
logstash-version: 8.1.3
logstash-branch: 8.1
elasticsearch-version: 8
prefix: ""
tags-latest: "8.1"
- output: "elasticsearch"
logstash-version: 8.2.3
logstash-branch: 8.2
elasticsearch-version: 8
prefix: ""
tags-latest: "8.2"
- output: "elasticsearch"
logstash-version: 8.3.3
logstash-branch: 8.3
elasticsearch-version: 8
prefix: ""
tags-latest: "8.3"
- output: "elasticsearch"
logstash-version: 8.4.2
logstash-branch: 8.4
elasticsearch-version: 8
prefix: ""
tags-latest: "8.4"
# v2 https://github.com/docker/build-push-action/blob/master/UPGRADE.md
steps:
- name: Checkout ✅
uses: actions/checkout@v4
- name: Config 📦
run: |
echo output=${{ matrix.output }}
echo prefix=${{ matrix.prefix }}
echo logstash-version=${{ matrix.logstash-version }}
echo logstash-branch=${{ matrix.logstash-branch }}
echo elasticsearch-version=${{ matrix.elasticsearch-version }}
echo tags-latest=${{ matrix.tags-latest }}
- name: Prepare 📦
id: prep
run: |
DOCKER_IMAGE=anasoid/jmeter-logstash
VERSION="${{ matrix.prefix }}${{ matrix.logstash-version }}"
echo "image=${DOCKER_IMAGE}" >> $GITHUB_OUTPUT
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT
if [[ "${{ matrix.with-plugins }}" == "true" ]];then echo "suffix=-plugins" >> $GITHUB_OUTPUT; else echo "suffix=" >> $GITHUB_OUTPUT; fi;
- name: Show Image Settings 📦
run: echo "IMAGE=${{ steps.prep.outputs.image }} VERSION=${{ steps.prep.outputs.version }}"
- name: Set up Docker Buildx 📦
id: buildx
uses: docker/setup-buildx-action@v3
- name: Inspect builder
run: |
echo "Name: ${{ steps.buildx.outputs.name }}"
echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}"
echo "Status: ${{ steps.buildx.outputs.status }}"
echo "Flags: ${{ steps.buildx.outputs.flags }}"
echo "Platforms: ${{ steps.buildx.outputs.platforms }}"
- name: Docker Build only - retain local Image 📦
id: build
uses: docker/build-push-action@v6
with:
context: .
file: docker/${{ matrix.output }}/Dockerfile
load: true
push: false
build-args: |
LOGSTASH_VERSION=${{ matrix.logstash-version }}
ELASTICSEARCH_VERSION=${{ matrix.elasticsearch-version }}
tags: |
${{ steps.prep.outputs.image }}:${{ matrix.prefix }}${{ matrix.logstash-version }}
${{ steps.prep.outputs.image }}:${{ matrix.prefix }}${{ matrix.logstash-branch }}
${{ steps.prep.outputs.image }}:${{ matrix.tags-latest }}
labels: |
org.opencontainers.image.source=${{ github.event.repository.html_url }}
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.version=${{ github.sha }}
- name: Result 📦
id: result
run: |
echo "currentImage=${{ steps.prep.outputs.image }}:${{ matrix.logstash-branch }}" >> $GITHUB_OUTPUT
- name: Validate config ☁️
run: docker run --rm -e "FILE_EXIT_AFTER_READ=false" ${{ steps.result.outputs.currentImage }} -t
#Publish on master
- name: Login to DockerHub 📦
if: ${{ github.ref_name == 'master' }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Push to Docker repo (on Push only) ☁️
if: ${{ github.ref_name == 'master' }}
run: docker image push --all-tags ${{ steps.prep.outputs.image }}