Files
snigdhaos-docker/.github/workflows/snigdhaos-docker.yml
2024-11-30 18:36:29 +05:30

61 lines
1.8 KiB
YAML

name: Snigdha OS Docker Image
on:
workflow_dispatch:
schedule:
- cron: '30 05 * * *' # Cron schedule for automatic builds (adjust as needed)
push:
branches:
- 'master'
jobs:
docker:
runs-on: ubuntu-latest
steps:
# Checkout repository
- name: Checkout repository
uses: actions/checkout@v3
# Set up QEMU for multi-architecture builds
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
# Set up Docker Buildx for advanced builds (multi-arch, caching)
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
# Login to Docker Hub using secrets for security
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# Cache Docker layers to speed up build time
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
# Build and push Docker image with multi-architecture support
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: snigdhaos/snigdhaos:latest
platforms: linux/amd64,linux/arm64 # Support for multiple architectures
cache-from: type=registry,ref=snigdhaos/snigdhaos:latest # Enable cache from Docker registry
# Optionally, tag the build with a version from GitHub
- name: Tag Docker image with version
run: |
VERSION=$(git describe --tags --abbrev=0)
docker tag snigdhaos/snigdhaos:latest snigdhaos/snigdhaos:${VERSION}
docker push snigdhaos/snigdhaos:${VERSION}