Skip to content

Build and Push Docker Image #47

Build and Push Docker Image

Build and Push Docker Image #47

Workflow file for this run

name: Build and Push Docker Image
on:
workflow_dispatch:
pull_request:
paths:
- 'runner/**'
- 'btc/**'
- 'rsync/**'
push:
branches:
- main
paths:
- 'runner/**'
- 'btc/**'
- 'rsync/**'
schedule:
- cron: '0 6 * * 1' # Every Monday at 06:00 UTC
jobs:
build-and-push:
if: github.event_name != 'schedule' || github.ref == 'refs/heads/main'
strategy:
fail-fast: false
matrix:
image: [runner, btc, rsync]
name: ${{ matrix.image }}
# runs-on: ubuntu-latest
runs-on: ubicloud-standard-2
permissions:
contents: read
packages: write
concurrency:
group: ${{ matrix.image }}
cancel-in-progress: false
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set image tag with lowercase repository
id: tag
run: |
REPO_LOWER=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')
IMAGE_NAME=ghcr.io/$REPO_LOWER/${{ matrix.image }}
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
TAG=${{ github.sha }}
else
TAG=latest
fi
echo "image=$IMAGE_NAME:$TAG" >> $GITHUB_OUTPUT
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: ./${{ matrix.image }}
file: ./${{ matrix.image }}/Dockerfile
push: true
tags: ${{ steps.tag.outputs.image }}