Skip to content

-fix docker build

-fix docker build #56

Workflow file for this run

# This workflow will build a Java project with Gradle
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
name: Create Release
on:
push:
tags:
- "*-ui"
jobs:
build:
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest ]
jdk: [ 11 ]
runs-on: ${{ matrix.os }}
env:
JDK_VERSION: ${{ matrix.jdk }}
outputs:
version: ${{ steps.vars.outputs.version }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set output
id: vars
run: |
echo "tag=$(echo $GITHUB_REF | cut -d / -f 3)" >> $GITHUB_OUTPUT
echo "version=$(echo $GITHUB_REF | cut -d / -f 3 | sed 's/.\{3\}$//')" >> $GITHUB_OUTPUT
- name: Check output
run: |
echo ${{ steps.vars.outputs.tag }}
echo ${{ steps.vars.outputs.version }}
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.jdk }}
distribution: 'temurin'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Cache Gradle packages
uses: actions/cache@v3
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Build
run: ./gradlew jar shadowJar
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.vars.outputs.tag }}
release_name: ${{ steps.vars.outputs.tag }}
body_path: RELEASE-NOTES.md
draft: false
prerelease: false
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./build/libs/wiremock-standalone-${{ steps.vars.outputs.version }}.jar
asset_name: wiremock-standalone-${{ steps.vars.outputs.version }}.jar
asset_content_type: application/java-archive
docker:
runs-on: ubuntu-latest
needs: [ build ]
strategy:
matrix:
versions:
- IMAGES:
- holomekc/wiremock-gui:latest-alpine
- holomekc/wiremock-gui:${{ needs.build.outputs.version }}-alpine
CONTEXT: alpine
PLATFORMS: linux/amd64
- IMAGES:
- holomekc/wiremock-gui:latest
- holomekc/wiremock-gui:${{ needs.build.outputs.version }}
CONTEXT: .
PLATFORMS: linux/amd64,linux/arm64,linux/arm/v7
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Checkout sources
uses: actions/checkout@main
with:
fetch-depth: 0
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build Wiremock Docker image
run: docker buildx build ${{ matrix.versions.CONTEXT }} --tag ${{ join(matrix.versions.IMAGES, ' --tag ') }} --build-arg WIREMOCK_VERSION=${{ needs.build.outputs.version }} --load
- name: Test Wiremock Docker image
run: |
# latest
docker container run -d --name test -p 8080:8080 ${{ matrix.versions.IMAGES[0] }}
timeout 10 bash -c 'while ! curl --fail http://localhost:8080/__admin/; do sleep 1; done'
timeout 10 bash -c 'while ! curl --fail http://localhost:8080/__admin/webapp; do sleep 1; done'
timeout 10 bash -c 'while ! curl --fail http://localhost:8080/__admin/webapp/mappings; do sleep 1; done'
timeout 10 bash -c 'while ! curl --fail http://localhost:8080/__admin/webapp/matched; do sleep 1; done'
timeout 10 bash -c 'while ! curl --fail http://localhost:8080/__admin/webapp/unmatched; do sleep 1; done'
timeout 10 bash -c 'while ! curl --fail http://localhost:8080/__admin/webapp/state; do sleep 1; done'
timeout 10 bash -c 'while ! curl --fail http://localhost:8080/__admin/webapp/files; do sleep 1; done'
docker container rm -f test
# version
docker container run -d --name test -p 8080:8080 ${{ matrix.versions.IMAGES[1] }}
timeout 10 bash -c 'while ! curl --fail http://localhost:8080/__admin/; do sleep 1; done'
timeout 10 bash -c 'while ! curl --fail http://localhost:8080/__admin/webapp; do sleep 1; done'
timeout 10 bash -c 'while ! curl --fail http://localhost:8080/__admin/webapp/mappings; do sleep 1; done'
timeout 10 bash -c 'while ! curl --fail http://localhost:8080/__admin/webapp/matched; do sleep 1; done'
timeout 10 bash -c 'while ! curl --fail http://localhost:8080/__admin/webapp/unmatched; do sleep 1; done'
timeout 10 bash -c 'while ! curl --fail http://localhost:8080/__admin/webapp/state; do sleep 1; done'
timeout 10 bash -c 'while ! curl --fail http://localhost:8080/__admin/webapp/files; do sleep 1; done'
docker container rm -f test
- name: Push wiremock-gui image to Docker HUB
run: docker buildx build ${{ matrix.versions.CONTEXT }} --tag ${{ join(matrix.versions.IMAGES, ' --tag ') }} --build-arg WIREMOCK_VERSION=${{ needs.build.outputs.version }} --platform ${{ matrix.versions.PLATFORMS }} --push