Skip to content

Build and push Ubuntu image #2

Build and push Ubuntu image

Build and push Ubuntu image #2

Workflow file for this run

name: Build and push Ubuntu image
on:
push:
tags:
- 'v*.*.*'
paths:
- ubuntu/**
schedule:
- cron: "0 0 * * 1" # Every Monday at 00:00
workflow_dispatch:
env:
REGISTRY: docker.io
IMAGE_OWNER: glitchcrab
IMAGE_NAME: ubuntu-debug
jobs:
debug_info:
name: Debug info
runs-on: self-hosted
steps:
- name: Print github context JSON
run: |
cat <<EOF
${{ toJson(github) }}
EOF
build-on-push-trigger:
runs-on: self-hosted
if: github.event_name == 'push'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v3
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ env.IMAGE_OWNER }}
password: ${{ secrets.DOCKERHUB_TOKEN_UBUNTU }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_OWNER }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{raw}}
type=schedule,pattern={{date 'YYYYMMDD'}}
type=raw,value=latest
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v5
with:
context: "./ubuntu"
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-on-any-other-trigger:
runs-on: self-hosted
if: github.event_name != 'push'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v3
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ env.IMAGE_OWNER }}
password: ${{ secrets.DOCKERHUB_TOKEN_UBUNTU }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_OWNER }}/${{ env.IMAGE_NAME }}
tags: |
type=schedule,pattern={{date 'YYYYMMDD'}}
type=raw,value=latest
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v5
with:
context: "./ubuntu"
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max