Publish Docker image #172
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: Publish Docker image | |
on: | |
schedule: | |
- cron: '0 0 * * *' # Once a day at midnight. | |
push: | |
branches: | |
- main | |
paths: | |
# Workflow file itself | |
- '.github/workflows/deploy.yml' | |
# Dockerfile | |
- 'Dockerfile' | |
workflow_dispatch: | |
permissions: | |
attestations: write | |
contents: read | |
id-token: write | |
packages: write | |
jobs: | |
push_to_registry: | |
name: Deploy image to registry | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v4 | |
- name: Docker Setup QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
# list of Docker images to use as base name for tags | |
images: | | |
ams21/tor-relay | |
ghcr.io/ams21/tor-relay | |
flavor: | | |
latest=true | |
prefix= | |
suffix= | |
# generate Docker tags based on the following events/attributes | |
tags: | | |
type=raw,value=edge | |
- name: Build and push Docker image | |
id: push | |
uses: docker/build-push-action@v6 | |
with: | |
context: ./ | |
push: true | |
pull: true | |
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/i386,linux/ppc64le,linux/riscv64 | |
annotations: ${{ steps.meta.outputs.annotations }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
- name: Attest Docker Hub | |
uses: actions/attest-build-provenance@v1 | |
with: | |
subject-name: index.docker.io/ams21/tor-relay | |
subject-digest: ${{ steps.push.outputs.digest }} | |
push-to-registry: true | |
- name: Attest GitHub Container Registry | |
uses: actions/attest-build-provenance@v1 | |
with: | |
subject-name: ghcr.io/ams21/tor-relay | |
subject-digest: ${{ steps.push.outputs.digest }} | |
push-to-registry: true |