-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #96 from JupiterOne/halo-159-add-global-workflow
Add Collector Image Workflow
- Loading branch information
Showing
1 changed file
with
79 additions
and
0 deletions.
There are no files selected for viewing
79 changes: 79 additions & 0 deletions
79
.github/workflows/halo_publish_integration_collector_image.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |