Skip to content

Commit

Permalink
feat: enable exposing of SSH agent
Browse files Browse the repository at this point in the history
  • Loading branch information
martinsolberg committed Feb 13, 2025
1 parent c9ec78c commit 57fbf97
Showing 1 changed file with 43 additions and 2 deletions.
45 changes: 43 additions & 2 deletions .github/workflows/workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ on:
type: string
description: Image name (repository path) within a registry.
required: true
ssh-agent:
type: boolean
default: false
description: Whether to start an SSH agent for the build.
tag-branch:
type: boolean
default: false
Expand Down Expand Up @@ -102,6 +106,9 @@ on:
token:
description: GitHub auth token.
required: true
ssh-deploy-key:
description: SSH key to load in the SSH agent
required: false
outputs:
image-digest:
description: The image digest for this build.
Expand Down Expand Up @@ -165,7 +172,37 @@ jobs:
username: ${{ secrets.registry-username }}
password: ${{ secrets.registry-password }}
-
if: inputs.cache == false
if: ${{ inputs.ssh-agent }}
name: Start SSH agent
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.ssh-deploy-key }}
-
if: inputs.cache == false && !inputs.ssh-agent
name: Build (no cache)
uses: docker/[email protected]
with:
file: ${{ inputs.context }}/${{ inputs.dockerfile }}
context: ${{ inputs.context }}
push: false
pull: true
tags: ${{ inputs.name }}:${{ steps.setup.outputs.unique-id }}
outputs: type=docker
-
if: inputs.cache == true && !inputs.ssh-agent
name: Build (with cache)
uses: docker/[email protected]
with:
file: ${{ inputs.context }}/${{ inputs.dockerfile }}
context: ${{ inputs.context }}
push: false
pull: true
tags: ${{ inputs.name }}:${{ steps.setup.outputs.unique-id }}
outputs: type=docker
cache-from: type=registry,ref=${{ inputs.registry-url }}/${{ inputs.name }}:${{ inputs.cache-tag }}
cache-to: type=registry,ref=${{ inputs.registry-url }}/${{ inputs.name }}:${{ inputs.cache-tag }},mode=max,ignore-error=true
-
if: inputs.cache == false && inputs.ssh-agent
name: Build (no cache)
uses: docker/[email protected]
with:
Expand All @@ -175,8 +212,10 @@ jobs:
pull: true
tags: ${{ inputs.name }}:${{ steps.setup.outputs.unique-id }}
outputs: type=docker
ssh: |
default=${{ env.SSH_AUTH_SOCK }}
-
if: inputs.cache == true
if: inputs.cache == true && inputs.ssh-agent
name: Build (with cache)
uses: docker/[email protected]
with:
Expand All @@ -188,6 +227,8 @@ jobs:
outputs: type=docker
cache-from: type=registry,ref=${{ inputs.registry-url }}/${{ inputs.name }}:${{ inputs.cache-tag }}
cache-to: type=registry,ref=${{ inputs.registry-url }}/${{ inputs.name }}:${{ inputs.cache-tag }},mode=max,ignore-error=true
ssh: |
default=${{ env.SSH_AUTH_SOCK }}
#
# Vulnerability scan
Expand Down

0 comments on commit 57fbf97

Please sign in to comment.