Skip to content

use variables instead of secrets for dockerhub public values #218

use variables instead of secrets for dockerhub public values

use variables instead of secrets for dockerhub public values #218

Workflow file for this run

name: 🐋 Docker Build
on:
push:
branches:
- dev
- main
tags:
- v*
jobs:
build:
name: Build and Publish Images
runs-on: ubuntu-latest
steps:
- name: Cache Docker Layers 📦
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Checkout 🚚
uses: actions/checkout@v4
- name: Docker Meta 📋
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository }}
${{ vars.DOCKER_HUB_USERNAME }}/${{ vars.DOCKER_HUB_REPO }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}.{{patch}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }}
flavor: |
latest=auto
- name: Login to Docker Hub 🐳
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Login to GHCR 🐙
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx 🐋
id: buildx
uses: docker/setup-buildx-action@v3
- name: Build and Push 🚀
id: docker_build
uses: docker/build-push-action@v5
with:
context: ./
file: ./Dockerfile
builder: ${{ steps.buildx.outputs.name }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache