Skip to content

Build and Push Alpine Images #2

Build and Push Alpine Images

Build and Push Alpine Images #2

name: Build and Push Alpine Images
on:
push:
branches-ignore:
- none
paths:
- "alpine/**"
- "alpine_dev/**"
workflow_dispatch:
jobs:
build:
runs-on: self-hosted
strategy:
fail-fast: false
matrix:
config:
- { dockerfile: "alpine/Dockerfile", context: "alpine", image_name: "alpine" }
- { dockerfile: "alpine_dev/Dockerfile", context: "alpine_dev", image_name: "alpine_dev" }
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set tag name based on branch
id: set_tag
run: |
if [[ "${{ github.ref_name }}" == "master" ]]; then
echo "::set-output name=tag::latest"
else
echo "::set-output name=tag::${{ github.ref_name }}"
fi
- name: Build and push
uses: docker/build-push-action@v5
with:
context: ${{ matrix.config.context }}
file: ${{ matrix.config.dockerfile }}
platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8
push: true
tags: hivesolutions/${{ matrix.config.image_name }}:${{ steps.set_tag.outputs.tag }}