Skip to content

Commit cdc0a96

Browse files
authored
Create docker-publish.yml
1 parent 3ac636c commit cdc0a96

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

.github/workflows/docker-publish.yml

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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+
schedule:
10+
- cron: '23 19 * * *'
11+
push:
12+
branches: [ main ]
13+
# Publish semver tags as releases.
14+
tags: [ 'v*.*.*' ]
15+
pull_request:
16+
branches: [ main ]
17+
18+
env:
19+
# Use docker.io for Docker Hub if empty
20+
REGISTRY: ghcr.io
21+
# github.repository as <account>/<repo>
22+
IMAGE_NAME: ${{ github.repository }}
23+
24+
25+
jobs:
26+
build:
27+
28+
runs-on: ubuntu-latest
29+
permissions:
30+
contents: read
31+
packages: write
32+
33+
steps:
34+
- name: Checkout repository
35+
uses: actions/checkout@v2
36+
37+
# Login against a Docker registry except on PR
38+
# https://github.com/docker/login-action
39+
- name: Log into registry ${{ env.REGISTRY }}
40+
if: github.event_name != 'pull_request'
41+
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
42+
with:
43+
registry: ${{ env.REGISTRY }}
44+
username: ${{ github.actor }}
45+
password: ${{ secrets.GITHUB_TOKEN }}
46+
47+
# Extract metadata (tags, labels) for Docker
48+
# https://github.com/docker/metadata-action
49+
- name: Extract Docker metadata
50+
id: meta
51+
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
52+
with:
53+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
54+
55+
# Build and push Docker image with Buildx (don't push on PR)
56+
# https://github.com/docker/build-push-action
57+
- name: Build and push Docker image
58+
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
59+
with:
60+
context: .
61+
push: ${{ github.event_name != 'pull_request' }}
62+
tags: ${{ steps.meta.outputs.tags }}
63+
labels: ${{ steps.meta.outputs.labels }}

0 commit comments

Comments
 (0)