Fix lint errores #198
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: buildx | |
on: | |
push: | |
pull_request: | |
jobs: | |
buildx: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Lint Dockerfile | |
uses: hadolint/[email protected] | |
with: | |
dockerfile: Dockerfile | |
# Prepare variables for building and tagging the image | |
- name: Prepare variables | |
id: prepare | |
run: | | |
GHCR_IMAGE=ghcr.io/${GITHUB_REPOSITORY} | |
DOCKER_PLATFORMS=linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/386,linux/ppc64le,linux/s390x | |
VERSION=$(echo ${GITHUB_REF#refs/*/} | sed 's/\//-/g') # Replace / with - in tag name | |
TAGS="${GITHUB_REPOSITORY}:${VERSION}" | |
if [[ $GITHUB_REF == refs/tags/* ]]; then | |
TAGS="$TAGS,${GITHUB_REPOSITORY}:latest" | |
elif [[ $VERSION == "master" ]]; then | |
TAGS="$TAGS,${GITHUB_REPOSITORY}:beta" | |
fi | |
GHCR_TAGS="${GHCR_IMAGE}:${VERSION}" | |
if [[ $GITHUB_REF == refs/tags/* ]]; then | |
GHCR_TAGS="$GHCR_TAGS,${GHCR_IMAGE}:latest" | |
elif [[ $VERSION == "master" ]]; then | |
GHCR_TAGS="$GHCR_TAGS,${GHCR_IMAGE}:beta" | |
fi | |
echo "platforms=${DOCKER_PLATFORMS}" >> $GITHUB_OUTPUT | |
echo "tags=${TAGS}" >> $GITHUB_OUTPUT | |
echo "ghcr-tags=${GHCR_TAGS}" >> $GITHUB_OUTPUT | |
# Set up QEMU for multi-platform builds | |
- name: Set up QEMU | |
id: qemu | |
uses: docker/setup-qemu-action@v3 | |
with: | |
image: tonistiigi/binfmt:latest | |
platforms: all | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
id: buildx | |
- name: Login to DockerHub | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Login to GHCR | |
if: github.event_name != 'pull_request' | |
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | |
- name: Debug Build on PR | |
run: | | |
docker buildx build --load . | |
# Test the built image | |
- name: Test | |
run: | | |
docker compose version | |
docker compose --file docker-compose.test.yml up --exit-code-from sut --timeout 10 --build | |
# Build and Push (if not a PR) | |
- name: Build and push | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.prepare.outputs.tags }} | |
platforms: ${{ steps.prepare.outputs.platforms }} | |
- name: Push to GHCR | |
if: github.event_name != 'pull_request' | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
push: true | |
tags: ${{ steps.prepare.outputs.ghcr-tags }} | |
platforms: ${{ steps.prepare.outputs.platforms }} | |
# Step 10: Update Docker Hub Description | |
- name: Update Docker Hub Description | |
if: startsWith(github.ref, 'refs/tags/') | |
uses: peter-evans/dockerhub-description@v4 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
short-description: ${{ github.event.repository.description }} |