Skip to content

Commit

Permalink
ci: add action to publish docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
ntarocco committed Dec 4, 2024
1 parent 81b44dc commit 4461970
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
53 changes: 53 additions & 0 deletions .github/actions/dockerpublish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Docker

on:
repository_dispatch:
types: publish-latest
workflow_dispatch:
inputs:
reason:
description: 'Reason'
required: false
default: 'Manual trigger'
push:
# Publish `master` as Docker `latest` image.
branches:
- master

env:
REGISTRY: ghcr.io
IMAGE_NAME: cds-backup

jobs:
push:

name: Publish images
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Extract GIT metadata for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}}
# set latest tag for default branch (master)
type=raw,value=latest,enable={{is_default_branch}}
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and publish image
uses: docker/build-push-action@v3
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
FROM nginx:1.18
FROM nginx:latest

COPY . /usr/share/nginx/html

0 comments on commit 4461970

Please sign in to comment.