diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml index 2eed90a..2bcea07 100644 --- a/.gitea/workflows/ci.yaml +++ b/.gitea/workflows/ci.yaml @@ -24,3 +24,29 @@ jobs: - run: | go mod tidy git diff --exit-code go.mod go.sum + publish: + name: Publish Docker Image + runs-on: ubuntu-latest + if: github.event_name == 'push' + needs: [build, tidy] + steps: + - uses: actions/checkout@v4 + - name: Log in to Gitea container registry + run: echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login gitea.stevedudenhoeffer.com --username "${{ secrets.REGISTRY_USER }}" --password-stdin + - name: Build and push Docker image + run: | + BRANCH="${{ github.ref_name }}" + SAFE_BRANCH="${BRANCH//\//-}" + REGISTRY="gitea.stevedudenhoeffer.com/steve/foreman" + + docker build -t "${REGISTRY}:${SAFE_BRANCH}" . + + if [ "${BRANCH}" = "main" ]; then + docker tag "${REGISTRY}:${SAFE_BRANCH}" "${REGISTRY}:latest" + fi + + docker push "${REGISTRY}:${SAFE_BRANCH}" + + if [ "${BRANCH}" = "main" ]; then + docker push "${REGISTRY}:latest" + fi