Skip to content

Commit be98b49

Browse files
authored
Create docker-publish.yml
1 parent 8e9d7aa commit be98b49

1 file changed

Lines changed: 61 additions & 0 deletions

File tree

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

0 commit comments

Comments
 (0)