81 lines
2.5 KiB
YAML
Executable File
81 lines
2.5 KiB
YAML
Executable File
name: Docker
|
|
|
|
on:
|
|
schedule:
|
|
- cron: '0 6 * * 0'
|
|
push:
|
|
branches: [ "main" ]
|
|
tags: [ 'v*.*.*' ]
|
|
pull_request:
|
|
branches: [ "main" ]
|
|
|
|
env:
|
|
# Use docker.io for Docker Hub if empty
|
|
REGISTRY: ghcr.io
|
|
IMAGE_NAME: ${{ github.repository }}
|
|
IMAGE: "sthopeless/gitea-actions-repos-compare"
|
|
|
|
|
|
jobs:
|
|
build:
|
|
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
id-token: write
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install cosign
|
|
if: github.event_name != 'pull_request'
|
|
uses: sigstore/cosign-installer@v3.8.1
|
|
with:
|
|
cosign-release: 'v2.2.4'
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Log into registry ${{ env.REGISTRY }}
|
|
if: github.event_name != 'pull_request'
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ env.REGISTRY }}
|
|
username: ${{ secrets.GH_USER }}
|
|
password: ${{ secrets.GH_TOKEN }}
|
|
|
|
- name: Extract Docker metadata
|
|
id: meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE }}
|
|
tags: |
|
|
type=raw,value=latest,enable={{is_default_branch}}
|
|
labels: |
|
|
org.opencontainers.image.source=${{ github.repository }}
|
|
org.opencontainers.image.revision=${{ github.sha }}
|
|
org.opencontainers.image.created=${{ steps.meta.outputs.created }}
|
|
org.opencontainers.image.authors=${{ steps.meta.outputs.authors }}
|
|
org.opencontainers.image.title=${{ github.repository }}
|
|
org.opencontainers.image.description=${{ github.repository }}
|
|
org.opencontainers.image.url=${{ github.event.repository.html_url }}
|
|
|
|
- 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 the published Docker image
|
|
if: ${{ github.event_name != 'pull_request' }}
|
|
env:
|
|
TAGS: ${{ steps.meta.outputs.tags }}
|
|
DIGEST: ${{ steps.build-and-push.outputs.digest }}
|
|
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST} |