Skip to content

Commit a440d7a

Browse files
Add github action for container building
1 parent e7fe88e commit a440d7a

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed

.github/workflows/docker-publish.yml

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

0 commit comments

Comments
 (0)