Merge pull request #430 from macbre/dependabot/github_actions/actions… #680
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: Build and test a Docker image | |
on: | |
push: | |
branches: [ master ] | |
pull_request: | |
jobs: | |
docker_build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/[email protected] | |
- name: Build the Docker image | |
env: | |
# @see https://docs.docker.com/develop/develop-images/build_enhancements/ | |
DOCKER_BUILDKIT: "1" | |
run: | | |
docker build . \ | |
--cache-from ghcr.io/macbre/index-digest:latest \ | |
--build-arg BUILDKIT_INLINE_CACHE=1 \ | |
--build-arg GITHUB_SHA=$(git rev-parse --short HEAD) \ | |
--tag ${{ github.repository }} | |
docker images | |
echo "## Image labels:" | |
docker inspect --format='{{json .Config.Labels}}' ${{ github.repository }} | jq | |
echo "## Image env vars:" | |
docker inspect --format='{{json .Config.Env}}' ${{ github.repository }} | jq | |
- name: Check the version | |
run: | | |
docker run ${{ github.repository }} --version | |
docker_test: | |
runs-on: ubuntu-latest | |
needs: docker_build | |
services: | |
mysql: | |
image: mysql:8.0.22 | |
env: | |
MYSQL_ALLOW_EMPTY_PASSWORD: yes | |
MYSQL_DATABASE: index_digest | |
MYSQL_USER: test | |
MYSQL_PASSWORD: p4ss | |
ports: | |
- "53306:3306" | |
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | |
steps: | |
- name: Run the container and connect to the test database | |
run: | | |
docker ps | |
docker run --network=host ${{ github.repository }} mysql://test:[email protected]:53306/index_digest | tee /tmp/results | |
grep "Jolly, good! No issues to report" /tmp/results |