Merge pull request #7 from mrbandler/develop #14
Workflow file for this run
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
name: Docker | |
on: | |
push: | |
tags: ["v*.*.*"] | |
pull_request: | |
branches: ["master"] | |
jobs: | |
build: | |
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 | |
- name: Install cosign | |
if: github.event_name != 'pull_request' | |
uses: sigstore/[email protected] | |
- name: Setup Docker buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Log into Docker Hub | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Extract Docker metadata | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
mrbandler/bpt | |
tags: | | |
type=ref,event=branch | |
type=ref,event=pr | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}}.{{patch}} | |
- name: Build and push Docker image | |
id: build-and-push | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
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 | |
- name: Sign image with GitHub OIDC Token | |
if: github.event_name != 'pull_request' | |
run: | | |
cosign sign --yes --rekor-url "https://rekor.sigstore.dev/" ${{ steps.build-and-push.outputs.digest }} | |
- name: Verify signed image with GitHub OIDC Token | |
if: github.event_name != 'pull_request' | |
run: | | |
cosign verify --rekor-url "https://rekor.sigstore.dev/" ${{ steps.build-and-push.outputs.digest }} --certificate-identity "https://github.com/mrbandler/bpt-docker/.github/workflows/docker.yaml@refs/heads/master" --certificate-oidc-issuer "https://token.actions.githubusercontent.com" | jq . |