-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from cdalvaro/feat/release_image_with_github_a…
…ctions Publish image with GitHub actions
- Loading branch information
Showing
4 changed files
with
102 additions
and
26 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
name: Publish | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
release: | ||
types: | ||
- created | ||
|
||
env: | ||
GITHUB_REF_NAME: ${{ github.event.release.tag_name }} | ||
IMAGE_NAME: cdalvaro/saltstack-master | ||
PLATFORMS: linux/amd64 linux/arm64 linux/arm/v7 | ||
DOCKER_CLI_EXPERIMENTAL: enabled | ||
|
||
jobs: | ||
build-and-publish: | ||
name: Build and publish | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- 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: Instantiate docker buildx builder | ||
run: | | ||
docker buildx create --use | ||
docker buildx inspect --bootstrap | ||
- name: Cache latest images | ||
run: | | ||
for PLATFORM in ${PLATFORMS}; do | ||
docker pull --platform "${PLATFORM}" "${IMAGE_NAME}:latest" | ||
done | ||
- name: Log in to Docker Hub | ||
run: | | ||
echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u="${{ secrets.DOCKER_USERNAME }}" --password-stdin | ||
- name: Build and push Docker image | ||
run: | | ||
docker buildx build \ | ||
--platform "${PLATFORMS// /,}" \ | ||
--cache-from "${IMAGE_NAME}:latest" \ | ||
--push --progress plain \ | ||
--build-arg=VCS_REF="${GITHUB_SHA::7}" \ | ||
--build-arg=BUILD_DATE="$(date +"%Y-%m-%d %H:%M:%S%:z")" \ | ||
--tag="${IMAGE_NAME}:${GITHUB_REF_NAME:-latest}" . | ||
test: | ||
name: Test | ||
runs-on: ubuntu-latest | ||
needs: build-and-publish | ||
steps: | ||
- 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: Test images | ||
env: | ||
CONTAINER_NAME: salt_master_test | ||
run: | | ||
IMAGE_TAG="${GITHUB_REF_NAME:-latest}" | ||
DOCKER_IMAGE="${IMAGE_NAME}:${IMAGE_TAG}" | ||
for PLATFORM in ${PLATFORMS}; do | ||
echo "Testing docker image ${DOCKER_IMAGE} on platform ${PLATFORM} ..." | ||
# test | ||
docker pull -q --platform "${PLATFORM}" "${DOCKER_IMAGE}" | ||
docker run --rm -d --name "${CONTAINER_NAME}" "${DOCKER_IMAGE}" | ||
docker container ls | ||
sleep 20 | ||
docker exec "${CONTAINER_NAME}" salt --versions | ||
echo "healthcheck" | ||
docker exec "${CONTAINER_NAME}" /usr/local/sbin/healthcheck | ||
# cleanup | ||
docker stop ${CONTAINER_NAME} | ||
docker image rm "${DOCKER_IMAGE}" | ||
done |
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
This file was deleted.
Oops, something went wrong.