Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions .github/actions/pack/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ inputs:
description: "Enable DockerHub publishing"
required: false
default: "false"
push_image:
description: "Push the built image to registries (set to false for build-only validation)"
required: false
default: "true"

runs:
using: "composite"
Expand All @@ -71,13 +75,15 @@ runs:
echo dockerfile=${DOCKERFILE_PATH} >> ${GITHUB_OUTPUT}

- name: Login to GHCR
if: ${{ inputs.push_image == 'true' }}
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ inputs.action_token}}

- name: Configure AWS Credentials
if: ${{ inputs.push_image == 'true' }}
uses: aws-actions/configure-aws-credentials@8df5847569e6427dd6c4fb1cf565c83acfa8afa7 # v6.0.0
with:
aws-region: us-east-1
Expand All @@ -86,10 +92,11 @@ runs:

- name: Login to Amazon ECR
id: login-ecr
if: ${{ inputs.push_image == 'true' }}
uses: aws-actions/amazon-ecr-login@062b18b96a7aff071d4dc91bc00c4c1a7945b076 # v2.0.1

- name: Login to Docker Hub
if: ${{ inputs.enable_dockerhub == 'true' && inputs.dockerhub_username && inputs.dockerhub_token }}
if: ${{ inputs.push_image == 'true' && inputs.enable_dockerhub == 'true' && inputs.dockerhub_username && inputs.dockerhub_token }}
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
with:
registry: docker.io
Expand All @@ -107,7 +114,7 @@ runs:

- name: Extract metadata for DockerHub
id: meta-dockerhub
if: ${{ inputs.enable_dockerhub == 'true' }}
if: ${{ inputs.push_image == 'true' && inputs.enable_dockerhub == 'true' }}
uses: ./.github/actions/docker-metadata
with:
cache: "false"
Expand All @@ -118,12 +125,13 @@ runs:
with:
version: latest
cache-binary: false

- name: Combine tags for all registries
id: combine-tags
shell: bash
run: |
TAGS="${{ steps.meta.outputs.tags }}"
if [[ "${{ inputs.enable_dockerhub }}" == "true" ]]; then
if [[ "${{ inputs.push_image }}" == "true" && "${{ inputs.enable_dockerhub }}" == "true" ]]; then
DOCKERHUB_TAGS="${{ steps.meta-dockerhub.outputs.tags }}"
if [[ -n "$DOCKERHUB_TAGS" ]]; then
TAGS="$TAGS"$'\n'"$DOCKERHUB_TAGS"
Expand All @@ -139,7 +147,7 @@ runs:
with:
platforms: ${{ inputs.platforms }}
context: .
push: true
push: ${{ inputs.push_image == 'true' }}
sbom: true
provenance: mode=max
file: ${{ steps.setup_build_args.outputs.dockerfile }}
Expand All @@ -159,12 +167,15 @@ runs:
cache-to: type=gha,mode=max

- name: Run Trivy vulnerability scanner
if: ${{ inputs.push_image == 'true' }}
uses: aquasecurity/trivy-action@57a97c7e7821a5776cebc9bb87c984fa69cba8f1 # 0.35.0
with:
image-ref: ghcr.io/descope/${{steps.setup_build_args.outputs.repo_name}}@${{steps.push.outputs.digest}}
format: "table"
exit-code: ${{ inputs.fail_on_vulnerabilities == 'true' && '1' || '0' }}

- name: Attest
if: ${{ inputs.push_image == 'true' }}
uses: actions/attest@59d89421af93a897026c735860bf21b6eb4f7b26 # v4
id: attest
with:
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: CI

on: push
on:
push:
workflow_dispatch:

env:
DATABASE_PASSWORD: passwordless
Expand Down Expand Up @@ -87,6 +89,11 @@ jobs:

- name: Pack and Upload
uses: ./.github/actions/pack
with:
push_image: ${{ github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch' }}
enable_dockerhub: "true"
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }}
Comment on lines +92 to +96

Copilot AI Mar 10, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ci.yml runs on every push, and enabling Docker Hub publishing unconditionally here will publish branch/CI tags to docker.io (the docker-metadata action generates multiple branch-derived tags). If the intent is “during the release process” only, gate Docker Hub publishing to tags and/or the default branch (e.g., via a job/step if: or by making enable_dockerhub conditional on github.ref_type/is_default_branch).

Copilot uses AI. Check for mistakes.
Comment on lines +94 to +96

Copilot AI Mar 10, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With enable_dockerhub forced to true, runs where DOCKERHUB_USERNAME/DOCKERHUB_TOKEN aren’t configured (e.g., forks or environments without these secrets) will still execute the DockerHub metadata/tag path and attempt to push DockerHub tags, but won’t log in (login is conditional on creds in .github/actions/pack/action.yml). Consider making enable_dockerhub conditional on the secrets being non-empty, or skipping the entire pack step/job when the Docker Hub secrets are unavailable.

Copilot uses AI. Check for mistakes.
env:
RELEASE_APP_ID: ${{ secrets.RELEASE_APP_ID }}
RELEASE_APP_PEM: ${{ secrets.RELEASE_APP_PEM }}
Loading