Skip to content

Commit

Permalink
IHS-84 Tagger container pipeline (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
adedw authored Sep 28, 2024
1 parent 971a998 commit df3438c
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 7 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ on:

jobs:
codecov:
env:
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages

runs-on: ubuntu-latest

steps:
Expand All @@ -18,7 +15,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
dotnet-version: '8.0.x'

- name: Restore dependencies
working-directory: ./tests/ImageHosting.Storage.UnitTests
Expand Down
86 changes: 86 additions & 0 deletions .github/workflows/publish-container-tagger.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Publish Tagger Hosted Service to GitHub container registry

on:
push:
branches: [ "master" ]

env:
REGISTRY: ghcr.io
IMAGE_NAME: image-hosting-storage-tagger


jobs:
publish-container:
runs-on: ubuntu-latest

permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

# Install the cosign tool except on PR
# https://github.com/sigstore/cosign-installer
- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/[email protected]
with:
cosign-release: 'v2.2.2'

# Set up BuildKit Docker container builder to be able to build
# multi-platform images and export cache
# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

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

# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v5
with:
context: .
file: ./src/ImageHosting.Storage.Tagger/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

# Sign the resulting Docker image digest except on PRs.
# This will only write to the public Rekor transparency log when the Docker
# repository is public to avoid leaking data. If you would like to publish
# transparency data even for private images, pass --force to cosign below.
# https://github.com/sigstore/cosign
- name: Sign the published Docker image
if: ${{ github.event_name != 'pull_request' }}
env:
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
TAGS: ${{ steps.meta.outputs.tags }}
DIGEST: ${{ steps.build-and-push.outputs.digest }}
# This step uses the identity token to provision an ephemeral certificate
# against the sigstore community Fulcio instance.
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: Publish to GitHub container registry
name: Publish WebAPI to GitHub container registry

on:
push:
branches: [ "master" ]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
IMAGE_NAME: image-hosting-storage-webapi


jobs:
Expand Down
1 change: 0 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ services:
- postgres
- kafka
- kafka-init-new-images
- kafka-init-categories

image-tagger:
container_name: image-tagger
Expand Down

0 comments on commit df3438c

Please sign in to comment.