2023-09-15 15:27:42 +02:00
|
|
|
# This workflow will publish a docker image for every full release to the GitHub package repository
|
|
|
|
|
|
|
|
name: Create Docker Image on Release
|
|
|
|
|
|
|
|
on:
|
|
|
|
release:
|
2024-02-11 14:38:41 +01:00
|
|
|
# Allow pre-releases
|
|
|
|
types: [published]
|
2023-09-15 15:27:42 +02:00
|
|
|
|
|
|
|
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
|
2023-09-23 00:09:51 +02:00
|
|
|
image_name: ghcr.io/sillytavern/sillytavern
|
2023-09-15 15:27:42 +02:00
|
|
|
|
|
|
|
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
|