Skip to content

Commit

Permalink
Add a GitHub action for sign and release
Browse files Browse the repository at this point in the history
Signed-off-by: S m, Aruna <[email protected]>
  • Loading branch information
arsulegai committed Oct 19, 2024
1 parent 3a0ed5a commit 79c0c3c
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/sign-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Sign and release the container image

on:
workflow_dispatch:

jobs:
build:

permissions:
id-token: write
contents: read
packages: write

runs-on: ubuntu-latest

steps:
# Checkout code
- name: Checkout code
uses: actions/checkout@v4

# Set up Docker Buildx
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

# Step 3: Log in to GitHub Container Registry
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Step 4: Build and push Docker image
- name: Read version from file
id: get_version
run: echo "version=$(cat VERSION)" >> $GITHUB_ENV

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
tags: ghcr.io/${{ github.repository }}:${{ env.version }}

# Step 5: Get the latest release of cosign github action
- uses: sigstore/[email protected]

# Step 6: Use GitHub's OIDC token
- name: Keyless sign the Docker image
run: |
version=${{ env.version }}
cosign sign --yes ghcr.io/${{ github.repository }}:${{ env.version }} \
--oidc-issuer https://token.actions.githubusercontent.com

0 comments on commit 79c0c3c

Please sign in to comment.