Skip to content

Commit ad3f671

Browse files
Create docker-publish.yml
1 parent e0f9af6 commit ad3f671

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

.github/workflows/docker-publish.yml

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

0 commit comments

Comments
 (0)