Skip to content

Commit

Permalink
Merge pull request #96 from JupiterOne/halo-159-add-global-workflow
Browse files Browse the repository at this point in the history
Add Collector Image Workflow
  • Loading branch information
zemberdotnet authored Sep 19, 2023
2 parents e1e980a + b1a36a4 commit e649126
Showing 1 changed file with 79 additions and 0 deletions.
79 changes: 79 additions & 0 deletions .github/workflows/halo_publish_integration_collector_image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Build and Package Collector Image

on:
workflow_call:
inputs:
registry:
description: 'The image repository where the image should be pushed'
type: string
required: false
default: 'ghcr.io'
image-name:
description:
'The name of the image. Defaults to repository name (ex.
jupiterone/graph-github)'
type: string
default: ${{ github.repository }}
required: false
secrets:
GHCR_USERNAME:
description: 'GHCR Username to authenticate and publish with'
required: true
GHCR_PASSWORD:
description: 'GHCR password to authenticate and publish with'
required: true

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Cosign
uses: sigstore/cosign-installer@v3

- name: Lowercase the image name
run:
echo "IMAGE_NAME=$(echo "${{ inputs.image-name }}" | tr '[:upper:]'
'[:lower:]')" >>${GITHUB_ENV}

# Login against a Docker registry
# https://github.com/docker/login-action
- name: Log into registry ${{ inputs.registry }}
uses: docker/login-action@v2
with:
registry: ${{ inputs.registry }}
username: ${{ secrets.GHCR_USERNAME }}
password: ${{ secrets.GHCR_PASSWORD }}

# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ inputs.registry }}/${{ env.IMAGE_NAME }}

# Build and push Docker image
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

# Sign the Docker image (Using OIDC Token for "keyless signing")
# https://github.com/sigstore/cosign-installer
- name: Sign the images with GH OIDC Token
run:
COSIGN_REPOSITORY=${{ inputs.registry }}/${{ env.IMAGE_NAME
}}-signatures cosign sign -y ${{ inputs.registry}}/${{ env.IMAGE_NAME
}}@${{ steps.build-and-push.outputs.DIGEST }}

0 comments on commit e649126

Please sign in to comment.