diff --git a/.forgejo/variables.yml b/.forgejo/variables.yml new file mode 100644 index 0000000..798e5ab --- /dev/null +++ b/.forgejo/variables.yml @@ -0,0 +1,21 @@ +# Required Variables for CI/CD Pipeline + +# Variables (set in Forgejo repository settings under Variables) +variables: + FORGEJO_REGISTRY: + description: "Your Forgejo registry URL (e.g., forgejo.yourdomain.com)" + required: true + + FORGEJO_OWNER: + description: "Your Forgejo username or organization name" + required: true + + FORGEJO_USER: + description: "Username for registry authentication" + required: true + +# Secrets (set in Forgejo repository settings under Secrets) +secrets: + FORGEJO_TOKEN: + description: "Access token for Forgejo registry authentication" + required: true \ No newline at end of file diff --git a/.forgejo/workflows/docker-build.yml b/.forgejo/workflows/docker-build.yml new file mode 100644 index 0000000..3fd47e5 --- /dev/null +++ b/.forgejo/workflows/docker-build.yml @@ -0,0 +1,48 @@ +name: Build and Publish Docker Image + +on: + push: + branches: [ main ] + tags: [ 'v*' ] + pull_request: + branches: [ main ] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ vars.FORGEJO_REGISTRY }}/${{ vars.FORGEJO_OWNER }}/personal-digital-asset-manager + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=sha + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to Container Registry + if: github.event_name != 'pull_request' + uses: docker/login-action@v2 + with: + registry: ${{ vars.FORGEJO_REGISTRY }} + username: ${{ vars.FORGEJO_USER }} + password: ${{ secrets.FORGEJO_TOKEN }} + + - name: Build and Push + uses: docker/build-push-action@v4 + with: + context: . + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max \ No newline at end of file