Skip to content

try to fix the devcontainer cosign #22

try to fix the devcontainer cosign

try to fix the devcontainer cosign #22

Workflow file for this run

name: docker
on:
push:
branches: ["main"]
tags: ["v*.*.*"]
paths:
- .devcontainer/Dockerfile
- .github/workflows/docker.yaml
pull_request:
branches: ["main"]
paths:
- .devcontainer/Dockerfile
- .github/workflows/docker.yaml
workflow_dispatch:
jobs:
docker:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
# Install the cosign tool except on PR
# https://github.com/sigstore/cosign-installer
- name: Install cosign
uses: sigstore/[email protected]
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/[email protected]
with:
tags: |
type=semver,pattern={{version}}
type=ref,event=pr
type=sha,enable={{is_default_branch}},prefix={{date 'YYYYMMDD-HHmmss'}}-,suffix=,format=short
# Uses the cached prebuilt image and adds
# devcontainer features and metadata before pushing
- name: Add devcontainer extras and push
uses: devcontainers/[email protected]
with:
cacheFrom: ghcr.io/${{ github.repository }}
imageName: ghcr.io/${{ github.repository }}
imageTag: ${{ join(steps.meta.outputs.tags) }}
skipContainerUserIdUpdate: true
platform: linux/amd64,linux/arm64
runCmd: spin --version
push: always
# Sign the resulting Docker image digest except on PRs.
- name: Sign the published Docker image
env:
IMAGE: ghcr.io/${{ github.repository }}
TAGS: ${{ steps.meta.outputs.tags }}
run: |
for tag in "${TAGS[@]}"; do
IMAGE_TAG="ghcr.io/${IMAGE}:${tag}"
DIGEST=$(docker image ls "$IMAGE_TAG" --digests --format='{{.Digest}}')
cosign sign --yes "${IMAGE_TAG}@${DIGEST}"
done