Skip to content

Commit 1661e40

Browse files
committed
chore: deploy with GitHub Actions
1 parent f4f5433 commit 1661e40

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

.github/workflows/docker-publish.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Docker
2+
3+
# This workflow uses actions that are not certified by GitHub.
4+
# They are provided by a third-party and are governed by
5+
# separate terms of service, privacy policy, and support
6+
# documentation.
7+
8+
on:
9+
push:
10+
branches: [ "main" ]
11+
tags:
12+
- 'v*.*.*'
13+
14+
env:
15+
# Use docker.io for Docker Hub if empty
16+
REGISTRY: ghcr.io
17+
# github.repository as <account>/<repo>
18+
IMAGE_NAME: ${{ github.repository }}
19+
20+
21+
jobs:
22+
build:
23+
24+
runs-on: ubuntu-latest
25+
permissions:
26+
contents: read
27+
packages: write
28+
# This is used to complete the identity challenge
29+
# with sigstore/fulcio when running outside of PRs.
30+
id-token: write
31+
32+
steps:
33+
- name: Checkout repository
34+
uses: actions/checkout@v4
35+
36+
# Set up BuildKit Docker container builder to be able to build
37+
# multi-platform images and export cache
38+
# https://github.com/docker/setup-buildx-action
39+
- name: Set up Docker Buildx
40+
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
41+
42+
# Login against a Docker registry except on PR
43+
# https://github.com/docker/login-action
44+
- name: Log into registry ${{ env.REGISTRY }}
45+
if: github.event_name != 'pull_request'
46+
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
47+
with:
48+
registry: ${{ env.REGISTRY }}
49+
username: ${{ github.actor }}
50+
password: ${{ secrets.GITHUB_TOKEN }}
51+
52+
# Extract metadata (tags, labels) for Docker
53+
# https://github.com/docker/metadata-action
54+
- name: Extract Docker metadata
55+
id: meta
56+
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
57+
with:
58+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
59+
60+
# Build and push Docker image with Buildx (don't push on PR)
61+
# https://github.com/docker/build-push-action
62+
- name: Build and push Docker image
63+
id: build-and-push
64+
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
65+
with:
66+
context: .
67+
push: ${{ github.event_name != 'pull_request' }}
68+
tags: ${{ steps.meta.outputs.tags }}
69+
labels: ${{ steps.meta.outputs.labels }}
70+
cache-from: type=gha
71+
cache-to: type=gha,mode=max

0 commit comments

Comments
 (0)