Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 2.5.0 to 2.6.1. - [Release notes](https://github.com/docker/build-push-action/releases) - [Commits](https://github.com/docker/build-push-action/compare/v2.5.0...v2.6.1) --- updated-dependencies: - dependency-name: docker/build-push-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
175 lines
5.3 KiB
YAML
175 lines
5.3 KiB
YAML
name: Build and test Docker image
|
|
|
|
on:
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
paths-ignore:
|
|
- "./**/*.md"
|
|
- "LICENSE"
|
|
|
|
env:
|
|
IMAGE_NAME: localhost:5000/cdalvaro/docker-salt-master:${{ github.sha }}
|
|
REGISTRY_PATH: ${{ github.workspace }}/registry
|
|
CACHE_PATH: /tmp/.buildx-cache
|
|
|
|
jobs:
|
|
build:
|
|
name: Build
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v2.3.4
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v1.2.0
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v1.4.1
|
|
with:
|
|
driver-opts: network=host
|
|
|
|
- name: Start Docker registry
|
|
run: |
|
|
docker run --rm --detach --publish 5000:5000 \
|
|
--volume ${REGISTRY_PATH}:/var/lib/registry \
|
|
--name registry registry:2
|
|
|
|
- name: Cache Docker layers
|
|
uses: actions/cache@v2.1.6
|
|
with:
|
|
path: ${{ env.CACHE_PATH }}
|
|
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
|
restore-keys: |
|
|
${{ runner.os }}-buildx-
|
|
|
|
- name: Build docker-salt-master image
|
|
uses: docker/build-push-action@v2.6.1
|
|
with:
|
|
context: .
|
|
file: ./Dockerfile
|
|
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
|
cache-from: |
|
|
type=local,src=${{ env.CACHE_PATH }}
|
|
ghcr.io/cdalvaro/docker-salt-master:latest
|
|
cache-to: type=local,dest=${{ env.CACHE_PATH }}
|
|
push: true
|
|
tags: ${{ env.IMAGE_NAME }}
|
|
|
|
- name: Stop Docker registry
|
|
run: docker stop registry
|
|
|
|
- name: Upload Docker registry data for testing
|
|
uses: actions/upload-artifact@v2
|
|
with:
|
|
name: docker-registry-data
|
|
path: ${{ env.REGISTRY_PATH }}/
|
|
|
|
test:
|
|
name: Test
|
|
runs-on: ubuntu-latest
|
|
needs: build
|
|
strategy:
|
|
matrix:
|
|
platform: [linux/amd64, linux/arm64, linux/arm/v7]
|
|
env:
|
|
DOCKER_CLI_EXPERIMENTAL: enabled
|
|
SALTAPI_URL: https://localhost:8000/
|
|
SALTAPI_USER: salt_api
|
|
SALTAPI_PASS: 4wesome-Pass0rd
|
|
SALTAPI_EAUTH: pam
|
|
steps:
|
|
- name: Download Docker registry data from build job
|
|
uses: actions/download-artifact@v2
|
|
with:
|
|
name: docker-registry-data
|
|
path: ${{ env.REGISTRY_PATH }}
|
|
|
|
- name: Enable Docker experimental
|
|
run: |
|
|
# Enable docker daemon experimental support.
|
|
echo '{"experimental": true}' | sudo tee /etc/docker/daemon.json
|
|
sudo systemctl restart docker
|
|
# Install QEMU multi-architecture support for docker buildx.
|
|
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
|
|
|
|
- name: Start Docker registry
|
|
run: |
|
|
docker run --rm --detach --publish 5000:5000 \
|
|
--volume ${REGISTRY_PATH}:/var/lib/registry \
|
|
--name registry registry:2
|
|
sleep 10
|
|
|
|
- name: Import Docker images
|
|
run: docker pull --platform ${{ matrix.platform }} ${IMAGE_NAME}
|
|
|
|
- name: Docker inspect
|
|
run: docker buildx imagetools inspect ${IMAGE_NAME} | grep '${{ matrix.platform }}'
|
|
|
|
- name: Launch docker container
|
|
run: |
|
|
# Create configuration files
|
|
mkdir -p /tmp/config/
|
|
cat > /tmp/config/salt-api.conf <<EOF
|
|
external_auth:
|
|
${SALTAPI_EAUTH}:
|
|
${SALTAPI_USER}:
|
|
- .*
|
|
- '@runner'
|
|
- '@wheel'
|
|
- '@jobs'
|
|
EOF
|
|
|
|
# Run test instance
|
|
docker run --rm --detach --name saltstack_master \
|
|
--publish 4505:4505 --publish 4506:4506 --publish 8000:8000 \
|
|
--env 'SALT_API_SERVICE_ENABLED=true' \
|
|
--env 'SALT_API_USER_PASS=${{ env.SALTAPI_PASS }}' \
|
|
--platform ${{ matrix.platform }} \
|
|
--volume /tmp/config:/home/salt/data/config:ro \
|
|
${IMAGE_NAME}
|
|
|
|
# Wait for salt-master bootup
|
|
sleep 60
|
|
|
|
- name: Show salt versions
|
|
run: docker exec saltstack_master salt --versions
|
|
|
|
- name: Test image calling healthcheck
|
|
run: docker exec saltstack_master /usr/local/sbin/healthcheck
|
|
|
|
- name: Test salt-api authentication
|
|
id: salt_api_auth
|
|
run: |
|
|
SALTAPI_TOKEN=$(curl -sSk https://localhost:8000/login \
|
|
-H 'Accept: application/x-yaml' \
|
|
-d username=${{ env.SALTAPI_USER }} \
|
|
-d password=${{ env.SALTAPI_PASS }} \
|
|
-d eauth=${{ env.SALTAPI_EAUTH }} | grep 'token:' | cut -d' ' -f 4)
|
|
[ -n "${SALTAPI_TOKEN}" ] || exit 1
|
|
echo "::set-output name=token::${SALTAPI_TOKEN}"
|
|
|
|
- name: Test salt-api command
|
|
run: |
|
|
curl -sSk https://localhost:8000 \
|
|
-H 'Accept: application/x-yaml' \
|
|
-H 'X-Auth-Token: ${{ steps.salt_api_auth.outputs.token }}' \
|
|
-d client=runner \
|
|
-d tgt='*' \
|
|
-d fun=test.stream
|
|
|
|
- name: Setup Python
|
|
uses: actions/setup-python@v2.2.2
|
|
with:
|
|
python-version: 3.8
|
|
|
|
- name: Install salt-pepper
|
|
run: pip install salt-pepper
|
|
|
|
- name: Test salt-pepper
|
|
run: pepper --client runner test.stream
|
|
|
|
- name: Cleanup
|
|
run: |
|
|
docker stop saltstack_master registry
|