Merge pull request #1341 from jertel/jertel/fixsmtpcert #474
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: publish_image | |
on: | |
push: | |
# Publish `master` as Docker `latest` image. | |
branches: | |
- master | |
tags: | |
- 2.* | |
env: | |
IMAGE_NAME: elastalert2 | |
DOCKER_REPO: jertel/elastalert2 | |
jobs: | |
push: | |
environment: Main | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Log into GitHub Registry | |
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin | |
- name: Log into Docker Registry | |
run: echo "${{ secrets.DOCKER_TOKEN }}" | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin | |
- name: Install buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v3 | |
with: | |
version: latest | |
- name: Build and Push multi-arch to Docker Hub | |
run: | | |
# Strip git ref prefix from version | |
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') | |
# Use Docker `latest` tag convention | |
[ "$VERSION" == "master" ] && VERSION=latest | |
TAG2="" | |
if [[ "$VERSION" == "2."* ]]; then | |
TAG2="--tag $DOCKER_REPO:2" | |
fi | |
echo VERSION=$VERSION | |
echo TAG2=$TAG2 | |
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes | |
docker buildx build \ | |
--platform=linux/amd64,linux/arm64 \ | |
--output "type=image,push=true" \ | |
--file ./Dockerfile . \ | |
--tag $DOCKER_REPO:$VERSION $TAG2 | |
- name: Build and push image to GitHub | |
run: | | |
docker build . --file Dockerfile --tag $IMAGE_NAME | |
IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME | |
# Change all uppercase to lowercase | |
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') | |
# Strip git ref prefix from version | |
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') | |
# Use Docker `latest` tag convention | |
[ "$VERSION" == "master" ] && VERSION=latest | |
echo IMAGE_ID=$IMAGE_ID | |
echo VERSION=$VERSION | |
# Push to GitHub Package | |
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION | |
docker push $IMAGE_ID:$VERSION | |
if [[ "$VERSION" == "2."* ]]; then | |
# Push to GitHub Package | |
docker tag $IMAGE_NAME $IMAGE_ID:2 | |
docker push $IMAGE_ID:2 | |
fi |