Skip to content

Build image

Build image #6

Workflow file for this run

name: "Build image"
on:
[workflow_dispatch]
permissions:
contents: read
packages: write
jobs:
date:
name: Get current date
runs-on: ubuntu-latest
outputs:
date: ${{ steps.date.outputs.date }}
tag: ${{ steps.date.outputs.tag }}
steps:
- name: Get current date
id: date
run: |
echo "date=$(date --rfc-3339=seconds | sed 's/ /T/')" >> $GITHUB_OUTPUT
echo "tag=$(date +%Y%m%d-%H%M%S)" >> $GITHUB_OUTPUT
build:
name: Build and push image
needs: date
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: 'kubuntu'
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push image for amd64/arm64
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
file: ./Dockerfile
push: true
build-args: |
IMAGE_BUILD_DATE=${{ needs.date.outputs.date }}
labels: |
org.opencontainers.image.ref.name=${{ github.ref }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.version=kubuntu
tags: |
ghcr.io/${{ github.repository_owner }}/webtop:kubuntu
ghcr.io/${{ github.repository_owner }}/webtop:kubuntu-${{ needs.date.outputs.tag }}
${{ vars.DOCKERHUB_USERNAME }}/webtop:kubuntu
${{ vars.DOCKERHUB_USERNAME }}/webtop:kubuntu-${{ needs.date.outputs.tag }}