From 79ffb2e0dd951acfa3077c2bef4fefc4fdd3eefa Mon Sep 17 00:00:00 2001 From: navigaid Date: Mon, 30 Oct 2023 17:53:21 +0000 Subject: [PATCH] push docker image to ghcr.io --- .github/workflows/docker-image.yml | 31 +++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index cccc2b3..57d0d26 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -15,6 +15,31 @@ jobs: - run: docker build -f Dockerfile -t subdirectory/subshell:${{ github.sha }} . name: docker build + + - name: Login to ghcr + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - run: | + docker tag subdirectory/subshell:${{ github.sha }} ghcr.io/subdirectory/subshell:${{ github.sha }} + docker push subdirectory/subshell:${{ github.sha }} + name: docker push ghcr sha + + - run: | + docker tag subdirectory/subshell:${{ github.sha }} ghcr.io/subdirectory/subshell + docker push ghcr.io/subdirectory/subshell + if: github.ref == 'refs/heads/main' + name: docker push ghcr latest + + - run: | + docker tag subdirectory/subshell:${{ github.sha }} ghcr.io/subdirectory/subshell:${{ github.ref_name }} + docker push ghcr.io/subdirectory/subshell:${{ github.ref_name }} + name: docker push ghcr tag + + - name: Login to Docker Hub uses: docker/login-action@v1 with: @@ -22,17 +47,17 @@ jobs: password: ${{ secrets.DOCKERHUB_TOKEN }} - run: docker push subdirectory/subshell:${{ github.sha }} - name: docker push + name: docker push dockerhub sha - run: | docker tag subdirectory/subshell:${{ github.sha }} subdirectory/subshell docker push subdirectory/subshell if: github.ref == 'refs/heads/main' - name: docker push latest + name: docker push dockerhub latest # get git tag # https://github.com/orgs/community/discussions/26686 - run: | docker tag subdirectory/subshell:${{ github.sha }} subdirectory/subshell:${{ github.ref_name }} docker push subdirectory/subshell:${{ github.ref_name }} - name: docker push tag + name: docker push dockerhub tag