Skip to content

Publish in GitHub Package Registry #8

Publish in GitHub Package Registry

Publish in GitHub Package Registry #8

Workflow file for this run

name: Release
run-name: Publish in GitHub Package Registry
on:
push:
tags:
- 'v*'
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push-image:
runs-on: ubuntu-22.04
permissions:
contents: read
packages: write
steps:
- uses: earthly/actions-setup@v1
with:
version: v0.8.0
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push docker image
run: earthly --push --ci +docker --reg=${{ env.REGISTRY }}/${{ github.actor }} --tag=${{ github.ref_name }}
- name: Install Cosign
uses: sigstore/cosign-installer@v3.3.0
- name: Sign image with a key
run: |
cosign sign \
--key env://COSIGN_PRIVATE_KEY \
-a "repo=${{ github.repository }}" \
-a "ref=${{ github.ref_name }}" \
-a "ref=${{ github.sha }}" \
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ github.sha }}
env:
COSIGN_PRIVATE_KEY: ${{secrets.COSIGN_PRIVATE_KEY}}
COSIGN_PASSWORD: ${{secrets.COSIGN_PASSWORD}}