Added publishing of docker images on release (#1135)

* Added publishing of docker images on release

* Use proper project name

---------

Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
This commit is contained in:
Chris Kaiser 2023-09-15 15:27:42 +02:00 committed by GitHub
parent 0f1a0963fd
commit ba302e4aa0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 45 additions and 0 deletions

45
.github/workflows/docker-publish.yml vendored Normal file
View File

@ -0,0 +1,45 @@
# This workflow will publish a docker image for every full release to the GitHub package repository
name: Create Docker Image on Release
on:
release:
# Only runs on full releases not pre releases
types: [released]
env:
# This should allow creation of docker images even in forked repositories
# Image name may not contain uppercase characters, so we can not use the repository name
# Creates a string like: ghcr.io/SillyTavern/sillytavern
image_name: ghcr.io/${{ github.repository_owner }}/sillytavern
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
# Build docker image using dockerfile and tag it with branch name
# Assumes branch name is the version number
- name: Build the Docker image
run: |
docker build . --file Dockerfile --tag $image_name:${{ github.ref_name }}
# Login into package repository as the person who created the release
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Assumes release is the latest and marks image as such
- name: Docker Tag and Push
run: |
docker tag $image_name:${{ github.ref_name }} $image_name:latest
docker push $image_name:${{ github.ref_name }}
docker push $image_name:latest