From d01f3aca5bcba5d85803447321a21c4224755a7a Mon Sep 17 00:00:00 2001 From: Sergei Pikhovkin Date: Sun, 12 Jan 2025 01:39:58 +0200 Subject: [PATCH] ci: Add Docker image publishing on ghcr --- .github/workflows/publish.yaml | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index de677cd..93d12d6 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -5,7 +5,7 @@ on: types: [created] jobs: - build-and-publish: + build-and-publish-on-pypi: if: github.event_name == 'release' && github.event.action == 'created' runs-on: ubuntu-latest steps: @@ -23,3 +23,21 @@ jobs: - name: Publish package run : | hatch publish -u __token__ -a ${{ secrets.PYPI_API_TOKEN }} + + build-and-publish-on-ghcr: + if: github.event_name == 'release' && github.event.action == 'created' + runs-on: ubuntu-latest + env: + DJANGO_SETTINGS_MODULE: tests.conf.settings.demo + GHCR_IMAGE_NAME: "ghcr.io/pikhovkin/${GITHUB_REPOSITORY:10}" + TAG: ${GITHUB_REF:10} + steps: + - uses: actions/checkout@v3 + - name: Docker login + run: echo ${{ secrets.GHCR_TOKEN }} | docker login ghcr.io -u ${{ secrets.DOCKER_USERNAME }} --password-stdin + - name: Build the Docker image + run: | + docker build -f docker/Dockerfile -t ${{ env.GHCR_IMAGE_NAME }}-demo:${{ env.TAG }} . + - name: Docker push + run: | + docker push ${{ env.GHCR_IMAGE_NAME }}-demo:${{ env.TAG }}