name: Build and publish Docker image on: push: branches: - main workflow_dispatch: permissions: contents: read packages: write jobs: build-and-publish: runs-on: ubuntu-latest steps: - name: Check out source uses: builtin:checkout - name: Log in to Gitea Container Registry env: REGISTRY_USER: ${{ gitea.actor }} REGISTRY_TOKEN: ${{ secrets.GITEA_TOKEN }} run: printf '%s' "$REGISTRY_TOKEN" | docker login git.anchorhost.eu --username "$REGISTRY_USER" --password-stdin - name: Build and tag image env: COMMIT_SHA: ${{ gitea.sha }} run: | image='git.anchorhost.eu/anchorhost.eu/anchorhost-frontend' short_sha="$(printf '%.12s' "$COMMIT_SHA")" docker build \ --label "org.opencontainers.image.revision=$COMMIT_SHA" \ --tag "$image:main-$short_sha" \ --tag "$image:main-latest" \ . - name: Push image tags env: COMMIT_SHA: ${{ gitea.sha }} run: | image='git.anchorhost.eu/anchorhost.eu/anchorhost-frontend' short_sha="$(printf '%.12s' "$COMMIT_SHA")" docker push "$image:main-$short_sha" docker push "$image:main-latest" - name: Log out from Gitea Container Registry if: always() run: docker logout git.anchorhost.eu