update dockerhub workflow.

This commit is contained in:
Miroslav Šedivý 2025-03-30 20:36:15 +02:00
parent 409a5f1426
commit 518f41f9ff

View file

@ -1,8 +1,9 @@
name: "build and push amd64 images to Docker Hub" name: Build and Push to Docker Hub
on: on:
push: push:
branches: [ master ] branches:
- master
# #
# Run this action periodically to keep browsers up-to-date # Run this action periodically to keep browsers up-to-date
# even if there is no activity in this repo. # even if there is no activity in this repo.
@ -15,29 +16,47 @@ env:
jobs: jobs:
build-base: build-base:
name: Base Image
runs-on: ubuntu-latest runs-on: ubuntu-latest
# #
# do not run on forks # do not run on forks
# #
if: github.repository_owner == 'm1k1o' if: github.repository_owner == 'm1k1o'
steps: steps:
- name: Check Out Repo - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Extract metadata (tags, labels) for Docker
uses: docker/metadata-action@v5
id: meta
with:
images: ${{ env.DOCKER_IMAGE }}
tags: |
type=raw,value=base
- name: Login to Docker Hub - name: Login to Docker Hub
run: | uses: docker/login-action@v3
docker login --username "${DOCKER_USERNAME}" --password-stdin "${DOCKER_REGISTRY}" <<< "${DOCKER_TOKEN}" with:
env: username: ${{ secrets.DOCKER_USERNAME }}
DOCKER_REGISTRY: ${{ secrets.DOCKER_REGISTRY }} password: ${{ secrets.DOCKER_TOKEN }}
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }}
- name: Build base - name: Generate base Dockerfile
run: | run: go run docker/main.go -i Dockerfile.tmpl -o Dockerfile
./build -b ${DOCKER_IMAGE}:base
docker push ${DOCKER_IMAGE}:base
build: - name: Build and push
uses: docker/build-push-action@v6
with:
context: ./
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-app:
name: App Image
runs-on: ubuntu-latest runs-on: ubuntu-latest
# #
# do not run on forks # do not run on forks
@ -48,30 +67,50 @@ jobs:
# Will build all images even if some fail. # Will build all images even if some fail.
fail-fast: false fail-fast: false
matrix: matrix:
tags: [ firefox, waterfox, chromium, google-chrome, ungoogled-chromium, microsoft-edge, brave, vivaldi, opera, tor-browser, remmina, vlc, xfce, kde ] tag:
env: - firefox
DOCKER_TAG: ${{ matrix.tags }} - waterfox
- chromium
- google-chrome
- ungoogled-chromium
- microsoft-edge
- brave
- vivaldi
- opera
- tor-browser
- remmina
- vlc
- xfce
- kde
steps: steps:
- name: Check Out Repo - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Extract metadata (tags, labels) for Docker
uses: docker/metadata-action@v5
id: meta
with:
images: ${{ env.DOCKER_IMAGE }}
tags: |
type=raw,value=latest,enable=${{ matrix.tag == 'firefox' }}
type=raw,value=${{ matrix.tag }}
- name: Login to Docker Hub - name: Login to Docker Hub
run: | uses: docker/login-action@v3
docker login --username "${DOCKER_USERNAME}" --password-stdin "${DOCKER_REGISTRY}" <<< "${DOCKER_TOKEN}" with:
env: username: ${{ secrets.DOCKER_USERNAME }}
DOCKER_REGISTRY: ${{ secrets.DOCKER_REGISTRY }} password: ${{ secrets.DOCKER_TOKEN }}
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }}
- name: Build container - name: Build and push
run: | uses: docker/build-push-action@v6
./build -b ${DOCKER_IMAGE}:base -i ${DOCKER_IMAGE} with:
docker tag ${DOCKER_IMAGE}/${DOCKER_TAG} ${DOCKER_IMAGE}:${DOCKER_TAG} context: apps/${{ matrix.tag }}
docker push ${DOCKER_IMAGE}:${DOCKER_TAG} push: true
tags: ${{ steps.meta.outputs.tags }}
- name: Push latest tag labels: ${{ steps.meta.outputs.labels }}
if: ${{ matrix.tags == 'firefox' }} build-args: |
run: | BASE_IMAGE=${{ env.DOCKER_IMAGE }}:base
docker pull ${DOCKER_IMAGE}:${DOCKER_TAG} cache-from: type=gha
docker tag ${DOCKER_IMAGE}:${DOCKER_TAG} ${DOCKER_IMAGE}:latest cache-to: type=gha,mode=max
docker push ${DOCKER_IMAGE}:latest