name: Build and Publish on: push: branches: - main env: REGISTRY: ${{ format('{0}', replace(replace(github.server_url, 'https://', ''), 'http://', '')) }} CHART_NAME: ${{ github.event.repository.name }} IMAGE_NAME: ${{ github.event.repository.name }} jobs: build-release: runs-on: ubuntu-latest permissions: id-token: write contents: read steps: - name: Checkout repository uses: actions/checkout@v4 - uses: DeterminateSystems/determinate-nix-action@v3 - name: Build Docker Image via Nix Flake run: | nix build ./build#dockerImage --print-build-logs docker load < result - name: Log in to Gitea Container Registry uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Tag and Push Docker Image run: | VERSION=${{ github.run_number }} TARGET_IMAGE=${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }} # Auto-detect the built image name SOURCE_IMAGE=$(docker images --format "{{.Repository}}:{{.Tag}}" | head -n 1) docker tag $SOURCE_IMAGE $TARGET_IMAGE:$VERSION docker tag $SOURCE_IMAGE $TARGET_IMAGE:latest docker push $TARGET_IMAGE:$VERSION docker push $TARGET_IMAGE:latest - name: Setup Helm uses: azure/setup-helm@v4 with: version: v3.14.0 - name: Package Helm Chart run: | VERSION=${{ github.run_number }} helm package ops/chart --version $VERSION --app-version $VERSION - name: Push Helm Chart to Gitea Registry run: | VERSION=${{ github.run_number }} CHART_FILE=${{ env.CHART_NAME }}-${VERSION}.tgz curl -f --user "${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}" \ -X POST \ --upload-file ./$CHART_FILE \ "${{ github.server_url }}/api/packages/${{ github.repository_owner }}/helm/api/charts"