name: Build and Publish on: push: branches: - main env: REGISTRY: ${{ format('{0}', replace(replace(github.server_url, 'https://', ''), 'http://', '')) }} # Dynamically extracts just the repository name (e.g., 'my-repo' from 'owner/my-repo') CHART_NAME: ${{ github.event.repository.name }} IMAGE_NAME: ${{ github.event.repository.name }} jobs: build-release: runs-on: nix steps: - name: Checkout via Native Git env: GITEA_URL: ${{ github.server_url }} TOKEN: ${{ secrets.GITHUB_TOKEN }} REPO: ${{ github.repository }} SHA: ${{ github.sha }} run: | nix shell nixpkgs#coreutils STRIPPED_URL=$(echo $GITEA_URL | sed -e 's|^https://||' -e 's|^http://||') echo "Cloning from: $STRIPPED_URL" # Perform the clone git clone --depth 1 "https://token:${TOKEN}@${STRIPPED_URL}/${REPO}.git" . # Checkout the specific commit git checkout $SHA - name: Build Docker Image via Nix Flake run: | nix build ./build/#dockerImage docker load -i 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 }}/${{ env.IMAGE_NAME }} nix shell nixpkgs#docker # Replace 'nix-built-image:latest' with your flake's internal image name docker tag nix-built-image:latest $TARGET_IMAGE:$VERSION docker push $TARGET_IMAGE:$VERSION - name: Package Helm Chart run: | VERSION=${{ github.run_number }} nix shell nixpkgs#kubernetes-helm # Packages the chart using the dynamically injected repo name 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 --user "${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}" \ -X POST \ --upload-file ./$CHART_FILE \ "${{ github.server_url }}/api/packages/${{ github.repository_owner }}/helm/api/charts"