name: Publish Docker container on: push: branches: - main # or the default branch of your repository jobs: build-and-push: runs-on: ubuntu-latest permissions: contents: read packages: write steps: - name: Check out the repo uses: actions/checkout@v3 - name: Get short SHA id: short-sha run: echo "::set-output name=sha::$(echo $GITHUB_SHA | cut -c1-6)" - name: Log in to GitHub Container Registry uses: docker/login-action@v2 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push Docker image uses: docker/build-push-action@v6 with: context: . file: ./Dockerfile push: true tags: | ghcr.io/${{ github.repository }}/resourcespace:latest ghcr.io/${{ github.repository }}/resourcespace:${{ steps.short-sha.outputs.sha }}