From ba302e4aa0018aa0733ff26dbd2c8a2e0c6379f4 Mon Sep 17 00:00:00 2001 From: Chris Kaiser Date: Fri, 15 Sep 2023 15:27:42 +0200 Subject: [PATCH] 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> --- .github/workflows/docker-publish.yml | 45 ++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 .github/workflows/docker-publish.yml diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml new file mode 100644 index 000000000..fee50ace1 --- /dev/null +++ b/.github/workflows/docker-publish.yml @@ -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