Skip to content

feat: add validation for Docker Hub secrets in CI workflow #2

feat: add validation for Docker Hub secrets in CI workflow

feat: add validation for Docker Hub secrets in CI workflow #2

Workflow file for this run

name: docker
on:
push:
branches: [main]
tags: ['v*']
workflow_dispatch: {}
concurrency:
group: docker-${{ github.ref }}
cancel-in-progress: true
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup QEMU
uses: docker/setup-qemu-action@v3
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Validate secrets
run: |
if [ -z "${{ secrets.DOCKERHUB_USERNAME }}" ] || [ -z "${{ secrets.DOCKERHUB_TOKEN }}" ]; then
echo "Missing DOCKERHUB_USERNAME or DOCKERHUB_TOKEN secrets. Add them under Settings → Secrets and variables → Actions.";
exit 1;
fi
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: docker.io
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push (multi-arch, cached)
uses: docker/build-push-action@v6
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: ilhamsj/payload:latest
cache-from: type=gha
cache-to: type=gha,mode=max
provenance: false
sbom: false