Merge pull request #121 from OpenDataEnsemble/feature/formplayer-html… #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Synkronus Docker Build & Publish | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - dev | |
| paths: | |
| - 'synkronus/**' | |
| - '.github/workflows/synkronus-docker.yml' | |
| pull_request: | |
| paths: | |
| - 'synkronus/**' | |
| - '.github/workflows/synkronus-docker.yml' | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version tag (e.g., v1.0.0). If empty, tags will be derived from the current ref.' | |
| required: false | |
| type: string | |
| release: | |
| types: [published] | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: opendataensemble/synkronus | |
| jobs: | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| packages: write | |
| id-token: write | |
| attestations: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| with: | |
| platforms: all | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract metadata (tags, labels) | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| tags: | | |
| # For main branch: latest + version tag (manual dispatch) or release tag | |
| type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }} | |
| # When triggered via manual dispatch with a version input | |
| type=semver,pattern=v{{version}},enable=${{ github.event_name == 'workflow_dispatch' && github.event.inputs.version != '' }},value=${{ github.event.inputs.version }} | |
| type=semver,pattern=v{{major}}.{{minor}},enable=${{ github.event_name == 'workflow_dispatch' && github.event.inputs.version != '' }},value=${{ github.event.inputs.version }} | |
| # When triggered from a GitHub Release event, use the release tag name as the semver source | |
| type=semver,pattern=v{{version}},enable=${{ github.event_name == 'release' }},value=${{ github.event.release.tag_name }} | |
| type=semver,pattern=v{{major}}.{{minor}},enable=${{ github.event_name == 'release' }},value=${{ github.event.release.tag_name }} | |
| # For other branches: branch name (pre-release) | |
| type=ref,event=branch,enable=${{ github.event_name != 'release' && github.ref != 'refs/heads/main' }} | |
| # For PRs: pr-number | |
| type=ref,event=pr | |
| # SHA for traceability (only for non-release events) | |
| type=sha,prefix=sha-,enable=${{ github.event_name != 'release' && github.event_name != 'pull_request' }} | |
| labels: | | |
| org.opencontainers.image.title=Synkronus | |
| org.opencontainers.image.description=Synchronization API for offline-first applications | |
| org.opencontainers.image.vendor=Open Data Ensemble | |
| - name: Build and push Docker image | |
| id: build | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: ./synkronus | |
| file: ./synkronus/Dockerfile | |
| platforms: linux/amd64 | |
| 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 | |
| - name: Generate artifact attestation | |
| if: github.event_name != 'pull_request' | |
| uses: actions/attest-build-provenance@v1 | |
| with: | |
| subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| subject-digest: ${{ steps.build.outputs.digest }} | |
| push-to-registry: true |