Skip to content

Commit

Permalink
make sure to have secrets
Browse files Browse the repository at this point in the history
  • Loading branch information
robkooper committed Feb 11, 2025
1 parent 1a4af16 commit cb9ea37
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions .github/workflows/docker-build-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ on:
required: false
default: "linux/amd64"
type: string
secrets:
DOCKERHUB_USERNAME:
description: 'DockerHub username used to push images'
required: false
DOCKERHUB_PASSWORD:
description: 'DockerHub password used to push images'
required: false
GITHUB_TOKEN:
description: 'GitHub token used to push images to GitHub Container Registry'
required: false

jobs:
build:
Expand Down Expand Up @@ -66,13 +76,15 @@ jobs:

# create metadata for image
- name: Docker meta
env:
check_var: ${{ secrets.DOCKERHUB_USERNAME }}
id: meta
uses: docker/metadata-action@v5
with:
# list of Docker images to use as base name for tags
images: |
name=ghcr.io/${{ github.repository_owner }}/${{ github.repository }}/${{ steps.name.outputs.image_name }}
name=pecan/${{ steps.name.outputs.image_name }},enable=${{ github.event_name != 'pull_request' }}
name=ghcr.io/${{ github.repository_owner }}/${{ steps.name.outputs.image_name }}
name=pecan/${{ steps.name.outputs.image_name }},enable=${{ env.check_var != null }}
# generate Docker tags based on the following events/attributes
tags: |
type=schedule
Expand Down Expand Up @@ -100,7 +112,9 @@ jobs:
# login to registries
- name: Login to DockerHub
if: github.event_name != 'pull_request'
env:
check_var: ${{ secrets.DOCKERHUB_USERNAME }}
if: env.check_var != null && github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
Expand Down

0 comments on commit cb9ea37

Please sign in to comment.