Skip to content

Parameterise versions into Dockerfile #6

Parameterise versions into Dockerfile

Parameterise versions into Dockerfile #6

Workflow file for this run

name: Publish Docker image
on:
push:
tags:
- "*"
jobs:
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: maven
- name: Build with Maven
run: mvn -B package --file pom.xml
- name: Detect OpenSearch Version
id: opensearch
run: |
echo version=$(mvn -q -Dexec.executable=echo -Dexec.args='${opensearch.version}' --non-recursive exec:exec) >> $GITHUB_OUTPUT
- name: Detect Plugin Version
id: plugin
run: |
echo version=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec) >> $GITHUB_OUTPUT
- name: Log in to Docker Hub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: telicent/opensearch
- name: Set up QEMU
uses: docker/setup-qemu-action@master
with:
platforms: all
- name: Setup Docker buildx
id: buildx
uses: docker/setup-buildx-action@master
- name: Build, tag, and push image to DockerHub
uses: docker/build-push-action@v2
with:
builder: ${{ steps.buildx.outputs.name }}
platforms: linux/amd64,linux/arm64
push: true
context: .
file: ./Dockerfile
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
OPENSEARCH_VERSION=${{ steps.opensearch.outputs.version }}
PLUGIN_VERSION=${{ steps.plugin.outputs.version }}