diff --git a/.forgejo/workflows/docker-publish.yml b/.forgejo/workflows/docker-publish.yml index e615ef0..0c53d55 100644 --- a/.forgejo/workflows/docker-publish.yml +++ b/.forgejo/workflows/docker-publish.yml @@ -1,73 +1,69 @@ name: Build and Push Docker Image -# Controls when the workflow will run on: push: branches: - - main # Run on pushes to the main branch + - main # Adjust if your main branch is different tags: - - 'v*.*.*' # Run on pushes of tags like v1.0.0, v1.2.3 etc. + - 'v*.*.*' # Trigger on version tags -# Environment variables available to all jobs and steps in the workflow env: - # Use the Forgejo instance URL directly from the context - REGISTRY: ${{ forgejo.instance }} - # Construct the base image name using owner and repo name - IMAGE_BASE_NAME: ${{ forgejo.repository_owner }}/${{ forgejo.repository }} + REGISTRY: git.cmzi.uk + + # Use 'github' context variables as fallbacks for repo owner and name + IMAGE_BASE_NAME: ${{ github.repository_owner }}/${{ github.repository }} jobs: build-and-push: - runs-on: docker-cli # Or specify your preferred runner type that has Docker - permissions: # Needed for the action to interact with the registry + runs-on: ubuntu-latest # Or your preferred runner with Docker + permissions: contents: read - packages: write # Required to push to the container registry + packages: write # Still required for pushing to the registry steps: - name: Check out code uses: actions/checkout@v4 with: - fetch-depth: 0 # Fetches all history for all tags and branches - needed for metadata action - - # Optional: Set up QEMU for multi-platform builds (if needed) - # - name: Set up QEMU - # uses: docker/setup-qemu-action@v3 + fetch-depth: 0 # Recommended for metadata action - name: Set up Docker Buildx - id: buildx # Step ID for referencing outputs + id: buildx uses: docker/setup-buildx-action@v3 - name: Log in to Forgejo Container Registry - # Uses the automatically generated FORGEJO_TOKEN for authentication uses: docker/login-action@v3 with: - registry: ${{ env.REGISTRY }} - username: ${{ forgejo.actor }} # The user/actor that triggered the workflow - password: ${{ secrets.FORGEJO_TOKEN }} # Built-in secret provided by Forgejo Actions + registry: ${{ env.REGISTRY }} # Use the registry URL defined above + # Use 'github.actor' as a fallback for the username context + username: ${{ github.actor }} + # Use the Forgejo-specific token - this SHOULD still work if Actions are enabled + password: ${{ secrets.FORGEJO_TOKEN }} - name: Extract metadata (tags, labels) for Docker - id: meta # Step ID for referencing outputs + id: meta uses: docker/metadata-action@v5 with: + # Construct the full image name using the defined REGISTRY and IMAGE_BASE_NAME images: ${{ env.REGISTRY }}/${{ env.IMAGE_BASE_NAME }} - # Defines tagging strategy based on the event that triggered the workflow tags: | - # tag latest for default branch (e.g., main) - type=raw,value=latest,enable=${{ forgejo.ref == format('refs/heads/{0}', 'main') }} - # tag with the git branch name if it's a branch push + # Use 'github.ref' for branch/tag detection + type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }} # Adjust 'main' if needed type=ref,event=branch - # tag with the git tag name if it's a tag push (e.g., v1.0.0) type=ref,event=tag - # tag with the short git SHA - type=sha,format=short + type=sha,format=short # Tag with short Git SHA + # Add standard OCI labels using github context + labels: | + org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }} + org.opencontainers.image.revision=${{ github.sha }} + org.opencontainers.image.ref.name=${{ github.ref_name }} - name: Build and push Docker image uses: docker/build-push-action@v5 with: - context: . # Build context is the repository root - file: ./Dockerfile # Path to your Dockerfile (default) - # platforms: linux/amd64,linux/arm64 # Uncomment for multi-platform builds (requires QEMU step) - push: true # Push the image after building - tags: ${{ steps.meta.outputs.tags }} # Use tags generated by the metadata step - labels: ${{ steps.meta.outputs.labels }} # Add labels generated by the metadata step - cache-from: type=gha # Enable build cache using GitHub Actions cache (works with Forgejo too) + context: . + file: ./Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} # Use tags from metadata step + labels: ${{ steps.meta.outputs.labels }} # Use labels from metadata step + cache-from: type=gha cache-to: type=gha,mode=max \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml index d843f34..35eb1dd 100644 --- a/.idea/vcs.xml +++ b/.idea/vcs.xml @@ -1,4 +1,6 @@ - + + + \ No newline at end of file