Skip to content

Merge branch 'main' of https://github.com/Darkfella91/home-ops #42

Merge branch 'main' of https://github.com/Darkfella91/home-ops

Merge branch 'main' of https://github.com/Darkfella91/home-ops #42

name: Docker Image CI
on:
push:
branches:
- main
paths:
- '.devcontainer/Dockerfile'
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Extract Alpine Version from Dockerfile
id: extract_version
run: |
# Extract the version from the 'builder' line in the Dockerfile
ALPINE_VERSION=$(grep -oP '(?<=^FROM alpine:)[\d\.]+(?:-\d+)?' .devcontainer/Dockerfile | head -n 1)
ALPINE_VERSION=$(echo $ALPINE_VERSION | xargs)
echo "Alpine version: $ALPINE_VERSION"
echo "ALPINE_VERSION=$ALPINE_VERSION" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry (GHCR)
uses: docker/login-action@v3
with:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
- name: Convert Repository Name to Lowercase
id: lowercase_repo
run: |
# Convert the GitHub repository name to lowercase
LOWERCASE_REPO=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')
echo "Lowercase repository name: $LOWERCASE_REPO"
echo "LOWERCASE_REPO=$LOWERCASE_REPO" >> $GITHUB_ENV
- name: Build and Push Docker Image
uses: docker/build-push-action@v6
with:
push: true
tags: |
ghcr.io/${{ env.LOWERCASE_REPO }}:latest
ghcr.io/${{ env.LOWERCASE_REPO }}:${{ env.ALPINE_VERSION }}
platforms: linux/amd64
build-args: |
ALPINE_VERSION=${{ env.ALPINE_VERSION }}
file: .devcontainer/Dockerfile
context: .